This repo contains the code for websocket client to be used on frontend for communicating with AdonisJs websocket server. :rocket:
Table of Contents
## Setup Feel free to use the module with **Webpack**, **Browserify** for similar build tools that supports **CommonJs** module loading, or you can also drop the script file right from the CDN.
CommonJs
npm i --save adonis-websocket-client
CDN
You can grab the script file from unpkg.com.
## Getting Started
Getting started is simple.
const ws = // or available as global when using the script file from CDNconst io =
Connecting to a channel
AdonisJs comes with inbuilt support for channels and rooms. In order to communicate with the websocket server, you are required for connect to a channel first.
const chat = iochat
Emitting Messages
chat
Join A Room
const data = {}chat
Leave A Room
const data = {}chat
Using With Vuejs
I love Vuejs to be core and here's how you are going to use it with Vuejs.
const ws = const wsVuePlugin = { Vueprototype$io = }Vue
Now you make use of the $io
on all of your components.
Connect To A Channel
el: '#app' { this$io }
Listening for events
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.