Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有节点socket.io和ioredis通过节点的广播服务器。
socket.io
ioredis
但是,以我目前的形式,我一次只能订阅一个频道。
var Redis = require('ioredis'); var redis = new Redis(); redis.subscribe('mychannel');
考虑到我必须有无数的频道(例如,每个注册用户一个),我不能硬输入节点服务器上的每个频道。
我也尝试过redis.subscribe('*'),但没有成功。
redis.subscribe('*')
有光吗?
使用redis.psubscribe('*')并redis.on('pmessage', handlerFunction)成功了。
redis.psubscribe('*')
redis.on('pmessage', handlerFunction)