@socket.io/redis-emitter
Advanced tools
Changelog
5.0.0 (2022-09-07)
Important note! There is a non backward-compatible change regarding Date objects, which means that the adapter may not be able to properly decode them.
Changelog
4.0.0 (2021-03-17)
Important note: the name of the package was updated from socket.io-emitter
to @socket.io/redis-emitter
in order to better reflect the relationship with Redis.
Before:
const io = require("socket.io-emitter")({ host: "127.0.0.1", port: 6379 });
After:
const { Emitter } = require("@socket.io/redis-emitter");
const { createClient } = require("redis");
const redisClient = createClient();
const io = new Emitter(redisClient);
io.to()
is now immutablePreviously, broadcasting to a given room (by calling io.to()) would mutate the io instance, which could lead to surprising behaviors, like:
io.to("room1");
io.to("room2").emit(/* ... */); // also sent to room1
// or with async/await
io.to("room3").emit("details", await fetchDetails()); // random behavior: maybe in room3, maybe to all clients
Calling io.to()
(or any other broadcast modifier) will now return an immutable instance.