push-cluster
v1.0.2
Published
A scalable realtime push framework.
Downloads
7
Readme
node-push-cluster
A scalable realtime push framework.
Installation
$ npm install push-cluster
Usage
Server
var os = require('os');
var cluster = require('cluster');
var npc = require('push-cluster');
var port = 5223;
if (cluster.isMaster) {
var cups = os.cpus();
for (var i = 0, l = cups.length; i < l; ++i) {
cluster.fork();
}
} else {
var server = npc.createServer();
server.listen(port);
server.on('listening', function () {
console.log('Listening', port);
});
}
Client
var npc = require('push-cluster');
npc.connect('ws://localhost:5223', function (session) {
session.subscribe('test');
session.publish('test', 'Hello Node Push Cluster');
session.on('message', function (channel, data) {
console.log(channel, data);
});
});
Browser
// Coming soon