rockets

Server-side client for rtheunissen/rockets

This is a client for rockets.

See rockets-demo.

npm install rockets
var Rockets = require('rockets');
 
var client = new Rockets();
 
// Register events on the client. 
client.on('connect', function() {
 
  // Subscribe to the 'comments' channel. 
  client.subscribe('comments', {
 
    // Only receive comments in r/programming. 
    subreddit: 'programming'
 
    // Only receive comments that contain the pattern 'rockets'. 
    contains: [
      'rockets',
    ]
  });
 
});
 
client.on('comment', function(comment) {
  // Do something using the comment data. 
});
 
// Initiate the client's socket connection. 
client.connect();

Events can be registered with client.on('event', handler).

EventArgumentsDescription
connectConnection to the server has been established
disconnectConnection to the server has been lost
errorerrorError has occurred
modelmodelReceived model, either post or comment
commentmodelReceived a comment
postmodelReceived a post
NameArgumentsDescription
subscribechannel, [filters]Subscribes to a channel, with optional filters
availableReturns true if the socket connection is open
closeClose the connection to the server