Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/websocket-packet

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/websocket-packet

Verify,create adonis websocket packets

  • 1.0.6
  • latest
  • legacy
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
increased by22.53%
Maintainers
1
Weekly downloads
 
Created
Source

Websocket packets

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.

Travis

Installation

Node/Webpack

npm i --save @adonisjs/websocket-packet
const wsp = require('@adonisjs/websocket-packet')

// or
import wsp from '@adonisjs/websocket-packet'

console.log(wsp.codes)
wsp.isJoinPacket(packet)

CDN

<script src="https://unpkg.com/@adonisjs/websocket-packet"></script>
<script type="text/javascript">
  console.log(adonis.wsp.codes)
  console.log(adonis.wsp.isJoinPacket(packet))
</script>

Constants

codes : Object

Packet codes. The actual packet will have the numbers

fns

Fns to be exported

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 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
}

fns

Fns to be exported

Kind: global constant

isJoinPacket(packet) ⇒ Boolean

Validates if packet code is a JOIN code.

Kind: global function

ParamType
packetObject

isLeavePacket(packet) ⇒ Boolean

Validates if packet code is a LEAVE code.

Kind: global function

ParamType
packetObject

isOpenPacket(packet) ⇒ Boolean

Validates if packet code is a OPEN code.

Kind: global function

ParamType
packetObject

isJoinAckPacket(packet) ⇒ Boolean

Validates if packet code is a JOIN_ACK code.

Kind: global function

ParamType
packetObject

isJoinErrorPacket(packet) ⇒ Boolean

Validates if packet code is a JOIN_ERROR code.

Kind: global function

ParamType
packetObject

isLeaveAckPacket(packet) ⇒ Boolean

Validates if packet code is a LEAVE_ACK code.

Kind: global function

ParamType
packetObject

isLeaveErrorPacket(packet) ⇒ Boolean

Validates if packet code is a LEAVE_ERROR code.

Kind: global function

ParamType
packetObject

isEventPacket(packet) ⇒ Boolean

Validates if packet code is a EVENT code.

Kind: global function

ParamType
packetObject

isPingPacket(packet) ⇒ Boolean

Validates if packet code is a PING code.

Kind: global function

ParamType
packetObject

isPongPacket(packet) ⇒ Boolean

Validates if packet code is a PONG code.

Kind: global function

ParamType
packetObject

hasTopic(packet) ⇒ Boolean

Finding if a packet has a topic.

Kind: global function

ParamType
packetObject

isValidJoinPacket() ⇒ Boolean

Makes sure packet is a valid join packet. Do call isJoinPacket before calling this method.

Kind: global function

isValidLeavePacket() ⇒ Boolean

Makes sure packet is a valid leave packet. Do call isLeavePacket before calling this method.

Kind: global function

isValidEventPacket() ⇒ Boolean

Makes sure packet is a valid event packet. Do call isEventPacket before calling this method.

Kind: global function

joinPacket(topic) ⇒ Object

Makes a join packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string
ParamType
topicString

leavePacket(topic) ⇒ Object

Makes a leave packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string
ParamType
topicString

joinAckPacket(topic) ⇒ Object

Makes join acknowledge packet

Kind: global function
Throws:

  • Error If topic is not defined or is not a string
ParamType
topicString

joinErrorPacket(topic, message) ⇒ Object

Makes join error packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string
  • Error If message is not defined or not a string
ParamType
topicString
messageString

leaveAckPacket(topic) ⇒ Object

Makes leave packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string
ParamType
topicString

leaveErrorPacket(topic, message) ⇒ Object

Makes leave error packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string
  • Error If message is not defined or not a string
ParamType
topicString
messageString

eventPacket(topic, event, data) ⇒ Object

Makes the event packet

Kind: 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
ParamType
topicString
eventString
dataMixed

pingPacket() ⇒ Object

Makes ping packet

Kind: global function

pongPacket() ⇒ Object

Makes pong packet

Kind: global function

Keywords

FAQs

Package last updated on 14 Mar 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc