Auto Remove Room N seconds since is empty

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Auto Remove Room N seconds since is empty

Postby Tatanan » 06 Jul 2017, 11:35

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.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Auto Remove Room N seconds since is empty

Postby Lapo » 06 Jul 2017, 14:10

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
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 112 guests