In-server event emission #4587
-
Hi! Here's the schematic In this case it is done for role management in my app since socket contains a copy of a user to check for permissions rather than having to look it up from database every time |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! You can loop over the io.of("/").sockets.forEach((socket) => {
// ...
}); Reference: https://socket.io/docs/v4/server-api/#namespacesockets Please note that this only works with a single server, with multiple servers you will need to use the Reference: https://socket.io/docs/v4/server-api/#serverserversideemiteventname-args |
Beta Was this translation helpful? Give feedback.
Hi! You can loop over the
sockets
map:Reference: https://socket.io/docs/v4/server-api/#namespacesockets
Please note that this only works with a single server, with multiple servers you will need to use the
serverSideEmit()
method.Reference: https://socket.io/docs/v4/server-api/#serverserversideemiteventname-args