Socket.io使用Redis Pub/Sub 疑问 - CNode技术社区

Socket.io使用Redis Pub/Sub 疑问
发布于 12 年前 作者 sanvibyfish 6680 次浏览 最后一次编辑是 9 年前

Nodejs使用cluster,fork了4个instance出来

原先的代码

 socket.emit("chat", {message:'aa'},callback)

现在使用了redis pub/sub

this.pub.publish('chat', JSON.stringify(message))
 this.sub.on('message', function(channel, message) {
 //这里我怎么获取到之前的callback呢?
 socket.emit(channel, message);
 });

问题如上,我怎么在publish是把原本客户端传过来的callback一并带过去呢?

回到顶部

AltStyle によって変換されたページ (->オリジナル) /