0.2.1 • Published 10 years ago

socket.io-clusterhub v0.2.1

Weekly downloads
9
License
-
Repository
github
Last release
10 years ago

socket.io-clusterhub Build Status

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

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

0.2.1

10 years ago

0.2.0

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago