0.5.0 • Published 9 years ago

push-server v0.5.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

PushServer a minimal push server bridging together Redis pub/sub capability and SockJS.

Quick start

To install TwitterStreamClient, run:

npm install push-server

Setting up a push server connected to your local Redis instance is as simple as:

var http = require('http'),
    pushServer = require('push-server'),
    server = http.createServer();

pushServer.start(server);
server.listen(5000);

To send message to SockJS connected clients you only need to publish it on your local Redis pushserver channel.

// connect to local redis instance
var pushServerRedis = redis.createClient();

// send a message
pushServerRedis.publish('pushserver', 'A cool message for connected browser');

On the browser side, just use SockJS to connect to your new PushServer:

var socket = new SockJS('http://localhost:5000/pushserver');

socket.onmessage = function (message) {
    console.log(message);
};

You can configure PushServer by passing an options hash to connect():

pushServer.start(server, {
    channel: 'my-fancy-channel',
    redisUrl: 'redis://user:password@localhost:6379',
    prefix: '/fancyurlpath'
});

Licence

MIT