Hi,
Is there any way to remove a Room created by extension N seconds since the Room is empty?
I have the problem, when 2 players are playing in a Room and both disconnects (ex. 2 players playing on mobile device and they receive a message so minify the app) the Room is automatically removed. I would like the Room to be autoremoved after 1 or 2 minutes.
Is it possible? If not it would be a feature that I recommend to be developed.
Thanks.
Auto Remove Room N seconds since is empty
Re: Auto Remove Room N seconds since is empty
Hi,
sure it is possible.
There are multiple ways. One that comes to mind is this:
1 - create the Room by setting the "remove mode" to SFSRoomRemoveMode.NEVER_REMOVE, this way the auto-removal is disabled.
2 - if the Room runs an Extension add an event listener for SFSEvent.USER_LEAVE_ROOM.
3 - inside the event handler check if the Room is empty, if it is you can start a Scheduled Task that will run 1-2 minutes later and remove the Room
When the task runs you may want to check again if the Room is empty as somebody might have joined it? Well, this actually depends on your app logic. You could also "freeze" the Room after the last user is gone so that nobody can join, by calling Room.setActive(false).
Hope it helps
sure it is possible.
There are multiple ways. One that comes to mind is this:
1 - create the Room by setting the "remove mode" to SFSRoomRemoveMode.NEVER_REMOVE, this way the auto-removal is disabled.
2 - if the Room runs an Extension add an event listener for SFSEvent.USER_LEAVE_ROOM.
3 - inside the event handler check if the Room is empty, if it is you can start a Scheduled Task that will run 1-2 minutes later and remove the Room
When the task runs you may want to check again if the Room is empty as somebody might have joined it? Well, this actually depends on your app logic. You could also "freeze" the Room after the last user is gone so that nobody can join, by calling Room.setActive(false).
Hope it helps
Who is online
Users browsing this forum: No registered users and 112 guests