Verify,create adonis websocket packets
npm install @adonisjs/websocket-packetIf you are writing a Javascript client, this is the library you must use. When writing client libraries for other platforms, simply follow the docs and the code to create your implementations.

bash
npm i --save @adonisjs/websocket-packet
``js
const wsp = require('@adonisjs/websocket-packet')// or
import wsp from '@adonisjs/websocket-packet'
console.log(wsp.codes)
wsp.isJoinPacket(packet)
`CDN
`html
`Constants
Functions
- isJoinPacket(packet) ⇒
Boolean
Validates if packet code is a JOIN code.
- isLeavePacket(packet) ⇒
Boolean
Validates if packet code is a LEAVE code.
- isOpenPacket(packet) ⇒
Boolean
Validates if packet code is a OPEN code.
- isJoinAckPacket(packet) ⇒
Boolean
Validates if packet code is a JOIN_ACK code.
- isJoinErrorPacket(packet) ⇒
Boolean
Validates if packet code is a JOIN_ERROR code.
- isLeaveAckPacket(packet) ⇒
Boolean
Validates if packet code is a LEAVE_ACK code.
- isLeaveErrorPacket(packet) ⇒
Boolean
Validates if packet code is a LEAVE_ERROR code.
- isEventPacket(packet) ⇒
Boolean
Validates if packet code is a EVENT code.
- isPingPacket(packet) ⇒
Boolean
Validates if packet code is a PING code.
- isPongPacket(packet) ⇒
Boolean
Validates if packet code is a PONG code.
- hasTopic(packet) ⇒
Boolean
Finding if a packet has a topic.
- isValidJoinPacket() ⇒
Boolean
Makes sure packet is a valid join packet. Do call isJoinPacket
before calling this method.
- isValidLeavePacket() ⇒
Boolean
Makes sure packet is a valid leave packet. Do call isLeavePacket
before calling this method.
- isValidEventPacket() ⇒
Boolean
Makes sure packet is a valid event packet. Do call isEventPacket
before calling this method.
- joinPacket(topic) ⇒
Object
Makes a join packet
- leavePacket(topic) ⇒
Object
Makes a leave packet
- joinAckPacket(topic) ⇒
Object
Makes join acknowledge packet
- joinErrorPacket(topic, message) ⇒
Object
Makes join error packet
- leaveAckPacket(topic) ⇒
Object
Makes leave packet
- leaveErrorPacket(topic, message) ⇒
Object
Makes leave error packet
- eventPacket(topic, event, data) ⇒
Object
Makes the event packet
- pingPacket() ⇒
Object
Makes ping packet
- pongPacket() ⇒
Object
Makes pong packet
codes : Object
Packet codes. The actual packet will have the numbersKind: global constant
Example
`
{
OPEN: 0,
JOIN: 1,
LEAVE: 2,
JOIN_ACK: 3,
JOIN_ERROR: 4,
LEAVE_ACK: 5,
LEAVE_ERROR: 6,
EVENT: 7,
PING: 8,
PONG: 9
}
`
fns
Fns to be exportedisJoinPacket(packet) ⇒ Boolean
Validates if packet code is a JOIN code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isLeavePacket(packet) ⇒ Boolean
Validates if packet code is a LEAVE code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isOpenPacket(packet) ⇒ Boolean
Validates if packet code is a OPEN code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isJoinAckPacket(packet) ⇒ Boolean
Validates if packet code is a JOIN_ACK code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isJoinErrorPacket(packet) ⇒ Boolean
Validates if packet code is a JOIN_ERROR code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isLeaveAckPacket(packet) ⇒ Boolean
Validates if packet code is a LEAVE_ACK code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isLeaveErrorPacket(packet) ⇒ Boolean
Validates if packet code is a LEAVE_ERROR code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isEventPacket(packet) ⇒ Boolean
Validates if packet code is a EVENT code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isPingPacket(packet) ⇒ Boolean
Validates if packet code is a PING code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isPongPacket(packet) ⇒ Boolean
Validates if packet code is a PONG code.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
hasTopic(packet) ⇒ Boolean
Finding if a packet has a topic.Kind: global function
| Param | Type |
| --- | --- |
| packet | Object |
isValidJoinPacket() ⇒ Boolean
Makes sure packet is a valid join packet. Do call isJoinPacket
before calling this method.isValidLeavePacket() ⇒ Boolean
Makes sure packet is a valid leave packet. Do call isLeavePacket
before calling this method.isValidEventPacket() ⇒ Boolean
Makes sure packet is a valid event packet. Do call isEventPacket`ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
| Param | Type |
| --- | --- |
| topic | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
| Param | Type |
| --- | --- |
| topic | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or is not a string
| Param | Type |
| --- | --- |
| topic | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
- Error If message is not defined or not a string
| Param | Type |
| --- | --- |
| topic | String |
| message | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
| Param | Type |
| --- | --- |
| topic | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
- Error If message is not defined or not a string
| Param | Type |
| --- | --- |
| topic | String |
| message | String |
ObjectKind: global function
Throws:
- Error If topic is not defined or not a string
- Error If event is not defined
- Error If data is not defined
| Param | Type |
| --- | --- |
| topic | String |
| event | String |
| data | Mixed |
ObjectObjectKind: global function