-
-
Notifications
You must be signed in to change notification settings - Fork 75
Clarification needed on Rooms #535
-
|
I have been checking the documentation and the code but I still don't have a solid concept of how they behave exactly. I have a codebase that only has at most 1 Socket per room. This is so I can easily emit messages sent to the socket.io server via an internal HTTP api to the user they are meant for (the room name is the userid and its autojoined on connect). The behavior that would fit my usecase is:
I am uncertain which of these are default behavior and which have to be manually implemented. Messages aren't produced unless a client is connected, this is moreso to conserve memory (by avoiding queueing messages that will never be recieved) and ensure consitency (to avoid race conditions) |
Beta Was this translation helpful? Give feedback.
All reactions
Hi! I recommend you to read this:
https://socket.io/docs/v4/rooms/.
This may help you to better understand rooms.
To answer your three questions:
- When you broadcast a message to an inexistant room, it is dropped as there is no socket to send the message to.
- Rooms are automatically cleaned each time a socket disconnects.
- For your last point you need to manually implement something yourself maybe by checking if the socket exists with
get_socketand emitting from it or storing it in a map of pending messages to send on the socket connection.
Don't hesitate if you need other clarifications.
Replies: 1 comment
-
|
Hi! I recommend you to read this:
Don't hesitate if you need other clarifications. |
Beta Was this translation helpful? Give feedback.