Replies: 1 comment
-
|
For future readers, you can use the function getLocalSocketIds(room) {
const ids = io.of("/").adapter.rooms.get(room);
return ids ? [...ids] : [];
}
io.on("retrieve socket ids", (room, cb) => {
cb(getLocalSocketIds(room));
});
async function getAllSocketIds(room) {
const ids = getLocalSocketIds(room);
const responses = await io.serverSideEmitWithAck("retrieve socket ids", room);
responses.forEach((response) => {
ids.push(...response);
});
return ids;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’m wondering if there’s a way to retrieve only the socket IDs from a room in a multi-cluster setup, without using .in(room).fetchSockets().
The issue is that I need to perform this operation very frequently, and fetchSockets() returns the full remote socket instances, whereas I only need the socket IDs.
For context, I’m using the Redis Streams adapter.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions