https://github.com/fent/socket.io-clusterhub
socket.io storage powered by clusterhub for multi process applications.
https://github.com/fent/socket.io-clusterhub
cluster node socket-io
Last synced: 11 days ago
JSON representation
socket.io storage powered by clusterhub for multi process applications.
- Host: GitHub
- URL: https://github.com/fent/socket.io-clusterhub
- Owner: fent
- License: mit
- Created: 2012-02-14T22:30:44.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2018-05-17T04:43:46.000Z (almost 7 years ago)
- Last Synced: 2025-01-17T04:12:50.208Z (3 months ago)
- Topics: cluster, node, socket-io
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 68
- Watchers: 9
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# socket.io-clusterhub [](http://travis-ci.org/fent/socket.io-clusterhub)
A [socket.io](http://socket.io/) storage made with [clusterhub](https://github.com/fent/clusterhub). Syncs data between multi-process socket.io applications.
**Note:** Only works with socket.io version <= v0.9.0
# Usage
```js
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](https://mochajs.org/)```bash
npm test
```# License
MIT