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

Room Deletion #702

Closed
adityosnrost opened this issue May 1, 2018 · 8 comments
Closed

Room Deletion #702

adityosnrost opened this issue May 1, 2018 · 8 comments
Labels

Comments

@adityosnrost
Copy link

Hi,

I just would like to know if the room will be deleted automatically when a client / user is no longer on the room / room is empty ?

If not, how can I cleaned up empty rooms ?

Thank You

@miguelgrinberg
Copy link
Owner

Rooms are not automatically deleted. You can use the close_room() function for that. This function removes all the clients from that room, and then deletes the room.

@adityosnrost
Copy link
Author

@miguelgrinberg Thank you so much for your reply.

So, I need to close the room manually. I have some thought on implementing this manual way, like close room when user disconnecting and room is empty.

How do I check if the room is empty ? I see there is no function for that in the documentation.

Regarding to the default room when user connected, I have read that a connected client have socket#id as their default room. is this default room need to close manually like room that we made manually ?

Thank You

@miguelgrinberg
Copy link
Owner

You can't check if a room is empty unless your application keeps track of who's in each room. This is because Flask-SocketIO is a distributed server, each server process knows about a fraction of the complete state.

There is no need to close the id-based rooms, those go away on their own.

@adityosnrost
Copy link
Author

@miguelgrinberg thank you for your explanation.

Maybe I can use the message queue feature from multi worker documentation to track room and user connection. While I am planning to use multi worker and using Redis as message queue, maybe Redis got that information, right ?

May I know what Flask-Socketio store to message queue such as Redis ?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented May 2, 2018

Redis is used as a pub/sub provider, there is no data stored there. As I said, the state is partitioned among the many servers, there is no place you can go to see a consolidated state, and for that reason the list of participants in a room cannot be provided. But your application should be able to easily track that down in your own database.

@adityosnrost
Copy link
Author

Alright, I see. I understand know, thank you for your amazing explanation. I am building user tracking now.
Thank you so much

@valentin-ballester
Copy link

What about server restarts ? Because o keep track using a counter when user connects/disconnect, should i reset the value to 0 when server restart ?

@miguelgrinberg
Copy link
Owner

@valentin-ballester If your server restart does not involve disconnecting the users gracefully, then yes, you should. Or another method is to have a "last active" timestamp for each user, so after some time of inactivity the user is considered gone.

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

No branches or pull requests

3 participants