socket.io-redis-emitter
socket.io-redis-emitter copied to clipboard
Synchronous processing between 2 libraries
"socket.io-redis-emitter": io.to(id).emit(eventName);
"socket.io-redis-adapte": await io.of('/').adapter.remoteJoin('
I found the solution: redis v4 has a new update: await publisher.publish('channel', 'message'); and here is the code I modified the library "socket.io-redis-emitter" file index.js, hope it helps someone:
emit(ev, ...args) {
return new Promise(async (resolve) => {
if (exports.RESERVED_EVENTS.has(ev)) {
throw new Error(`"${ev}" is a reserved event name`);
}
// set up packet object
const data = [ev, ...args];
const packet = {
type: socket_io_parser_1.PacketType.EVENT,
data: data,
nsp: this.broadcastOptions.nsp,
};
const opts = {
rooms: [...this.rooms],
flags: this.flags,
except: [...this.exceptRooms],
};
const msg = msgpack.encode([UID, packet, opts]);
let channel = this.broadcastOptions.broadcastChannel;
if (this.rooms && this.rooms.size === 1) {
channel += this.rooms.keys().next().value + "#";
}
debug("publishing message to channel %s", channel);
await this.redisClient.publish(channel, msg);
resolve(true);
});
}
Hope admin will update this change soon
Please reopen if needed.