Git Product home page Git Product logo

adonis-websocket-packet's Introduction

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

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

adonis-websocket-packet's People

Contributors

thetutlage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ruby184

adonis-websocket-packet's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.