Skip to content
socket.io storage powered by clusterhub for multi process applications.
JavaScript
Find file
Failed to load latest commit information.
lib check `fn` is set May 11, 2014
test update test dependencies May 17, 2014
.gitignore first commit Feb 14, 2012
.travis.yml update node versions Feb 21, 2015
LICENSE first commit Feb 14, 2012
README.md socket.io version note Aug 17, 2014
package.json always use latest dev dependencies Feb 26, 2015

README.md

socket.io-clusterhub Build Status

A socket.io storage made with clusterhub. Syncs data between multi-process socket.io applications.

Note: Only works with socket.io version <= v0.9.0

Usage

var cluster = require('cluster');
var numCPUs = require('os').cpus().length;

// store must be initialized for master/worker processes
var store = new (require('socket.io-clusterhub'));

if (cluster.isMaster) {
  for (var i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

} else {
  var io = require('socket.io').listen(3000)
  console.log('Listening on port 3000');

  // set the store to the socket.io-clusterhub instance
  io.configure(function() {
    io.set('store', store);
  });

  io.sockets.on('connection', function(socket) {
    // use socket.io as normal
  });
}

Install

npm install socket.io-clusterhub

Tests

Tests are written with mocha

npm test

License

MIT

Something went wrong with that request. Please try again.