Redis pub/sub for chat server in node.js

前端 未结 2 1379
死守一世寂寞
死守一世寂寞 2021-01-31 12:41

I\'m trying to work the Redis Cookbook example:

var http = require(\'http\'),
io = require(\'socket.io\')
fs = require(\'fs\'),
redis = require(\'redis\'),
rc =          


        
2条回答
  •  无人及你
    2021-01-31 13:01

    I believe that the example from that book is missing something, I also read that book and wondered. You are subscribed to the Redis channel and are waiting for messages on the server side, but you never publish to that channel. What is missing is an event listener so when there is a websocket message, you publish that message to the redis channel.

提交回复
热议问题