Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request support for clustered socket rooms #20

Open
Timpan4 opened this issue Mar 19, 2024 · 4 comments
Open

Request support for clustered socket rooms #20

Timpan4 opened this issue Mar 19, 2024 · 4 comments
Labels
question Further information is requested

Comments

@Timpan4
Copy link

Timpan4 commented Mar 19, 2024

Socket.io has a concept of rooms for socket clients to join.

The Redis Adapter has support for clustered room emitting and room fetching via the allRooms() function.
This function allows any socket.io server to fetch all rooms that are connected to the same redis pub/sub namespace, regardless of which socket.io server the client connected to.

This allows to emit specific events to specific rooms, regardless of where the room was created.

We were trying to change from using the original Redis Adapter to this new stream based adapter due to the support for Connection state recovery. But for now we need to continue to use the original.

@darrachequesne
Copy link
Member

Hi! What do you mean by "clustered socket rooms"? Are you only missing the allRooms() method?

This allows to emit specific events to specific rooms, regardless of where the room was created.

This should already work. Isn't that the case for you?

@darrachequesne darrachequesne added the question Further information is requested label Mar 22, 2024
@Timpan4
Copy link
Author

Timpan4 commented Mar 25, 2024

What i mean by "clustered socket rooms" is more or less server 1 can emit to a room that only exists on server 3 and vice versa.

We're using the allRooms() method to get a list of all available rooms across the cluster.

I have not tested if emitting to a room that lives on a different server compared to the one I'm emitting from

@darrachequesne
Copy link
Member

My concern with the allRooms() of the Redis adapter is that it currently returns all rooms, including private ones (the ones named after the socket IDs), so it might return a lot of data.

That being said, I guess we could implement an allRooms() method for all adapters, which would exclude the private rooms and return the count of sockets for each room?

const rooms = await io.allRooms();

const count = rooms.get("room1");

@Timpan4 what do you think?

@Timpan4
Copy link
Author

Timpan4 commented Mar 25, 2024

Maybe something like this.

const rooms = await io.allRooms();

const socketsInRoom = rooms.get("room1");

That would mimic the Redis adapters functionality.

But excluding private ones would just be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants