adonis-websocket

Adonisjs websockets support

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
adonis-websocket
1.0.47 years ago7 years agoMinified + gzip package size for adonis-websocket in KB

Readme

AdonisJs WebSocket


Version Build Status Coverage Status Downloads License


Gitter Trello Support AdonisJs



Adonis Websocket is the official websockets provider for AdonisJs. It let you easily setup/authenticate channels and rooms with elegant syntax and power of ES2015 generators.:rocket:



Table of Contents



Setup

Follow the below instructions to setup this provider

Install

npm i --save adonis-websocket

Setting up the provider

All providers are registered inside bootstrap/app.js file.
const providers = [
  'adonis-websocket/providers/WsProvider'
]

Setting up the alias

Aliases makes it easier to reference a namespace with a short unique name. Aliases are also registered inside bootstrap/app.js file.
const aliases = {
  Ws: 'Adonis/Addons/Ws'
}

Setup process is done. Let's use the Ws provider now.

Getting Started

Feel free to skip this section and read the official documentation, if you are on version 3.2 or later.
If you are using older version of adonis-app. You are supposed to create couple of directories in order to setup the ecosystem.

Bash Commands

Below are the bash commands to create required directories. Equivalent commands for windows can be used.
mkdir app/Ws
mkdir app/Ws/Controllers
touch app/Ws/socket.js

Loading socket.js file.

Next we need to do is loading the socket.js file when starting the server. Which will be inside bootstrap/http.js file. Paste the below line of code after use(Helpers.makeNameSpace('Http', 'routes'))
use(Helpers.makeNameSpace('Ws', 'socket'))

Next, read the official documentation :book:

Contribution Guidelines

In favor of active development we accept contributions from everyone. You can contribute by submitting a bug, creating pull requests or even improving documentation.
You can find a complete guide to be followed strictly before submitting your pull requests in the Official Documentation.