Emit data only to local users when using redis adapter #5186
-
Hello, is there a method to send data exclusively to the users on the current server while using a Redis adapter? From my understanding, if I emit data, it will be sent to users on all servers, not just the ones connected to this server, since I’m using a Redis adapter with a cluster. I would like to have a namespace to remain 'private' to each server. Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
darrachequesne
Sep 14, 2024
Replies: 1 comment 1 reply
-
Hi! You can use the io.local.emit("hello"); Reference: https://socket.io/docs/v4/server-api/#flag-local The event will only be forwarded to the clients connected to the current server. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
brako
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! You can use the
local
broadcast modifier:Reference: https://socket.io/docs/v4/server-api/#flag-local
The event will only be forwarded to the clients connected to the current server.