Files
James Coglan 147e58bd12 Documentation.
2011-12-22 19:32:51 +00:00

26 lines
754 B
JavaScript

// Run by passing a port to listen on and optionally the port of another member
// of the cluster. The node will discover all the others itself.
//
// e.g.
// node server.js 8000 # initial master
// node server.js 8001 8000 # second member
var faye = require('faye'),
cluster = require('../lib/faye/cluster'),
port = process.argv[2],
remote = process.argv[3];
var server = new faye.NodeAdapter({mount: '/faye', timeout: 60}),
node = new cluster.Node('http://localhost:' + port + '/faye');
server.addExtension(node);
server.listen(port);
if (remote) node.connect('http://localhost:' + remote + '/faye');
server.bind('publish', function(clientId, channel, data) {
console.log(channel, data);
});