npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adonisjs/websocket-packet

v1.0.6

Published

Verify,create adonis websocket packets

Downloads

6,316

Readme

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

Functions

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

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

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

| Param | Type | | --- | --- | | topic | String |

leavePacket(topic) ⇒ Object

Makes a leave packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string

| Param | Type | | --- | --- | | topic | String |

joinAckPacket(topic) ⇒ Object

Makes join acknowledge packet

Kind: global function
Throws:

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

| Param | Type | | --- | --- | | topic | String |

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

| Param | Type | | --- | --- | | topic | String | | message | String |

leaveAckPacket(topic) ⇒ Object

Makes leave packet

Kind: global function
Throws:

  • Error If topic is not defined or not a string

| Param | Type | | --- | --- | | topic | String |

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

| Param | Type | | --- | --- | | topic | String | | message | String |

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

| Param | Type | | --- | --- | | topic | String | | event | String | | data | Mixed |

pingPacket() ⇒ Object

Makes ping packet

Kind: global function

pongPacket() ⇒ Object

Makes pong packet

Kind: global function