nodejs cluster

I am building nodejs - socket.io application with nodejs cluster.

socket.io-redis

var ioredis = require('socket.io-redis');
io.adapter(ioredis({ host: config.redisIp, port: config.redisPort }));

socket.io-emitter

var io = require('socket.io-emitter')({ host: settings.redisIp, port: settings.redisPort });
io.emit('test', 'test'); 

its working but, sending to all connected sockets. How can i select specific client without using room types. like,

io.to({_id: user._id}).emit('test', 'test'); //its not work. socket._id synchronized on connect event.

any idea for select specific client on socket.io cluster app ?


尝试这个:

var io = require('socket.io-emitter')({ host: settings.redisIp, port: settings.redisPort });
io.to(socketId).emit('test', 'test');
链接地址: http://www.djcxy.com/p/63672.html

上一篇: redis支持redis集群?

下一篇: nodejs集群