ctrl-web-socket-message
v1.0.1
Published
The Message class for web socket data.
Downloads
2
Readme
ctrl-react-web-socket
The Message class for web socket data.
Installation
Yarn is recommended for installation.
$ yarn add ctrl-web-socket-message
But you can still use npm
:
$ npm install --save ctrl-web-socket-message
Usage
const Message = require('ctrl-web-socket-message')
const message = new Message({
test: 'payload'
})
// Pseudo socket code
socket.emit('test event', message, callback)
Methods
Message constructor(Any payload)
Constructs a new message, automatically giving it a timestamp and id.
Message static Message.convert(Object rawMessage)
Converts a raw object into a Message. data
, timestamp
, and id
fields are
required.
License
Copyright (c) 2016 Martin Experiments LLC
MIT (https://www.opensource.org/licenses/MIT)