Skip to content

In-server event emission #4587

Answered by darrachequesne
Indeedornot asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! You can loop over the sockets map:

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 serverSideEmit() method.

Reference: https://socket.io/docs/v4/server-api/#serverserversideemiteventname-args

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Indeedornot
Comment options

@qiulang
Comment options

Answer selected by Indeedornot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants