webcastjs
A nodejs implementation of webcast.js
Install
npm i webcastjs
Usage
webcastjs
provides a client and a server
As a client
const Client = var client = 'ws://localhost:3000' // Insert hello object clientsomeArbitraryReadableStream
new Client(address, hello) extends Writable
Creates a new client object. Client objects can be used as a writable stream.
address
: aws://
address for the serverhello
: a hello object as described here
Client.sendMeta(data)
Broadcast arbitrary metadata
data
: anything
As a server
The webcast Server
is a modification on the standard ws.Server
. Websockets will be emitted like a regular ws.Server
while receiving an error handling filter in compliance with webcast.js specs.
const Server = const WebSocket = var server = port: 3000 }) server
new class Server(opts) extends EventEmitter
Creates a new webcast Server
opts
: See WebSocket.Server['Options']
emits connection(ws)
Emits whenever a new connection is successfully established
ws
: the websocket
ws emits
The websocket is modified to emit unique events
hello
: the first hello messagemetadata
: a change in metadataframe
: a valid webcast.js frame