Skip to content

Socket.io based realtime notifications with Rodeo.

License

Notifications You must be signed in to change notification settings

thisandagain/randy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Randy

Socket.io based realtime notifications with Rodeo.

Build Status

Installation

npm install node-randy

Server Setup

Randy setup is rather simple. To get a notifications server up and running simply:

var randy   = require('node-randy');
randy.listen(80, function (err) {
    // Let's do this!
});

Optionally, you can pass in Redis connection settings (see Matt Ranney's Redis module for details):

var randy   = require('node-randy');
randy.listen(80, {
    port:       3333,
    host:       '127.0.0.1',
    pass:       'wildturkey',
    options:    null
}, function (err) {
    // Jump the general lee off a cliff
});

Client Setup

The client side is vanilla socket.io and only requires handling of three actions: register, notice, and dismiss (and read optionally). For example:

var socket  = io.connect('//localhost');
var user    = 'test::user1234';

// Emit the "register" event with a unique user id and type (optional).
socket.emit('register', user);

// If a notice is received, display it!
socket.on('notice', function (notice) {
    alert(JSON.stringify(notice));

    // You can flag a persistent notice as "read", by emitting the "read" action
    socket.emit('read', {
        id:     notice.id,
        uid:    user
    });

    // In order to remove a persistent notice, you need to emit the "dismiss" action
    socket.emit('dismiss', {
        id:     notice.id,
        uid:    user
    });
});

Methods

  • listen

Socket.io Actions (Incoming)

  • notice

Socket.io Actions (Outgoing)

  • register
  • read
  • dismiss

To Test

npm test

About

Socket.io based realtime notifications with Rodeo.

Resources

License

Stars

Watchers

Forks

Packages

No packages published