Server-side client for rockets/rockets
This is a client for rockets/rockets.
npm install rockets
var Rockets = require'rockets';var client = ;// Register events on the client.clienton'connect'var include =// Only receive comments in r/programming.subreddit: 'programming'// Only receive comments that contain the pattern 'rockets'.contains:'rockets';var exclude =// Skip comments that contain the word "hack".contains:'hack';// Subscribe to the 'comments' channel.clientsubscribe'comments' include exclude;;clienton'comment'// Do something using the comment data.;// Initiate the client's socket connection.clientconnect;
Events can be registered with
|connect||Connection to the server has been established|
|disconnect||Connection to the server has been lost|
|error||error||Error has occurred|
|model||model||Received model, either post or comment|
|comment||model||Received a comment|
|post||model||Received a post|
|subscribe||channel, [include [, exclude]]||Subscribes to a channel, with optional include and exclude rules|
|close||Close the connection to the server|
Illustrations by Ken Samonte.