io.sockets.on('connection', function (socket) {
console.log('channel:--->' + 'lonso' + io.sockets.clients().length );
socket.on('disconnect', function(){
console.log('disconnect.........................' + io.sockets.clients().length);
});
redis_client.subscribe('lonso' + io.sockets.clients().length );
redis_client.on('message',
function (channel, message) {
console.log("server 1 channel:" + channel + ", msg:" + message);
socket.disconnect();
}
);
}); //Sub
for(var i=1; i<=5; i++) {
client.publish('lonso' + i,"test,i am test");
} //pub
在pub的时候sub订阅的频道会收到5次消息。怎么回事?