1.0.4 • Published 7 years ago

adonis-websocket v1.0.4

Weekly downloads
104
License
MIT
Repository
github
Last release
7 years ago

Table of Contents

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.

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:

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.