Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@adonisjs/websocket-packet
Advanced tools
This library is used to create/validate the websocket packets used by AdonisJs.
If 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.
npm i --save @adonisjs/websocket-packet
const wsp = require('@adonisjs/websocket-packet')
console.log(wsp.codes)
wsp.isJoinPacket(packet)
Object
Packet codes. The actual packet will have the numbers
Boolean
Validates if packet code is a JOIN
code.
Boolean
Validates if packet code is a LEAVE
code.
Boolean
Validates if packet code is a OPEN
code.
Boolean
Validates if packet code is a JOIN_ACK
code.
Boolean
Validates if packet code is a JOIN_ERROR
code.
Boolean
Validates if packet code is a LEAVE_ACK
code.
Boolean
Validates if packet code is a LEAVE_ERROR
code.
Boolean
Validates if packet code is a EVENT
code.
Boolean
Validates if packet code is a PING
code.
Boolean
Validates if packet code is a PONG
code.
Boolean
Finding if a packet has a topic.
Boolean
Makes sure packet is a valid join packet. Do call isJoinPacket
before calling this method.
Boolean
Makes sure packet is a valid leave packet. Do call isLeavePacket
before calling this method.
Boolean
Makes sure packet is a valid event packet. Do call isEventPacket
before calling this method.
Object
Makes a join packet
Object
Makes a leave packet
Object
Makes join acknowledge packet
Object
Makes join error packet
Object
Makes leave packet
Object
Makes leave error packet
Object
Makes the event packet
Object
Makes ping packet
Object
Makes pong packet
Object
Packet codes. The actual packet will have the numbers
Kind: 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
}
Boolean
Validates if packet code is a JOIN
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a LEAVE
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a OPEN
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a JOIN_ACK
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a JOIN_ERROR
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a LEAVE_ACK
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a LEAVE_ERROR
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a EVENT
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a PING
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Validates if packet code is a PONG
code.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Finding if a packet has a topic.
Kind: global function
Param | Type |
---|---|
packet | Object |
Boolean
Makes sure packet is a valid join packet. Do call isJoinPacket
before calling this method.
Boolean
Makes sure packet is a valid leave packet. Do call isLeavePacket
before calling this method.
Boolean
Makes sure packet is a valid event packet. Do call isEventPacket
before calling this method.
Object
Makes a join packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringParam | Type |
---|---|
topic | String |
Object
Makes a leave packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringParam | Type |
---|---|
topic | String |
Object
Makes join acknowledge packet
Kind: global function
Throws:
Error
If topic is not defined or is not a stringParam | Type |
---|---|
topic | String |
Object
Makes join error packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringError
If message is not defined or not a stringParam | Type |
---|---|
topic | String |
message | String |
Object
Makes leave packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringParam | Type |
---|---|
topic | String |
Object
Makes leave error packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringError
If message is not defined or not a stringParam | Type |
---|---|
topic | String |
message | String |
Object
Makes the event packet
Kind: global function
Throws:
Error
If topic is not defined or not a stringError
If body.event is not definedError
If body.data is not definedParam | Type |
---|---|
topic | String |
body | Object |
Object
Makes ping packet
Object
Makes pong packet
Kind: global function
FAQs
Verify,create adonis websocket packets
The npm package @adonisjs/websocket-packet receives a total of 1,387 weekly downloads. As such, @adonisjs/websocket-packet popularity was classified as popular.
We found that @adonisjs/websocket-packet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.