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

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一并带过去呢?

回到顶部