Skip to content

Utility methods with multiple nodes #4395

Discussion options

You must be logged in to vote

Hi! Yes, the Redis adapter is compatible with those methods.

By the way, Are socket objects read-only on other servers if we use fetchSockets?

On other servers, you'll get a object which exposes a subset of the methods of the Socket class:

const sockets = await io.fetchSockets();

for (const socket of sockets) {
  console.log(socket.id);
  console.log(socket.handshake);
  console.log(socket.rooms);
  console.log(socket.data);
  socket.emit(/* ... */);
  socket.join(/* ... */);
  socket.leave(/* ... */);
  socket.disconnect(/* ... */);
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hossein-zare
Comment options

@darrachequesne
Comment options

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