please help. I'm using nodejs cluster module: http://nodejs.org/docs/v0.6.18/api/cluster.html. I have the following code:
run.js
var cluster = require('cluster');
if (cluster.isMaster) {
require('os').cpus().forEach(function () {
cluster.fork();
});
} else {
require('./worker.js');
}
worker.js
var http = require('http'),
connect = require('connect'),
sio = require('socket.io'),
// create server
app = connect(),
server = http.createServer(app);
server.listenPort(80);
var io = sio.listen(server);
// io.sockets.on ....
All workers listen 80 port. Each connection serves a random worker(?). Can I switch worker, where user has connected?
sorry my bad english
If you really needed to switch you could use sockets / socket.io to communicate between your clusters and send your work around.
Otherwise, you can't. But just curious - why would you want to?
You should look into WebRTC which enables peer-to-peer connection which is great for multi-player games.
My 2 cents.