node package manager


Server-side client for rockets/rockets

This is a client for rockets/rockets.

See rockets/demo.

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

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

Event Arguments Description
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
Name Arguments Description
subscribe channel, [include [, exclude]] Subscribes to a channel, with optional include and exclude rules
available Returns true if the socket connection is open
close Close the connection to the server

Illustrations by Ken Samonte.