Closed DavraYoung closed 3 years ago
Hi! I was thinking about adding this feature with: https://github.com/socketio/socket.io-adapter/commit/1c9827ec1136e24094295907efaf4d4e6c2fef2f
Syntax (open to discussion):
const sockets = await io.in("room3").fetchSockets();
for (const socket of sockets) {
console.log(socket.rooms); // along with id & handshake
}
What do you think?
I needed to collect socket ids in order make them leave certain rooms and that functinality was covered in recent commit here. Thanks)
Good news, thanks a lot for the feedback :pray:
Let's make socketRooms return promise.
Sometimes it's usefull to know what rooms the specific socket is in. In single node, the Adapter.socketRooms(socketId) function works as intended.
However, with multiple socket.io servers connected through socket.io-redis adapter, it is impossible to know what rooms the socket is in, if the socket is from different node.
Making Adapter.socketRooms function to return promise will allow other adapters to implement logic of getting socket rooms even if the socket is not stored in current node.