Hi, I'm building an app that enables users to create room for players before them joining it, but I need the room to destroy itself after a few hours if no one joined it. Right now, if some players join a room, when they leave the room calls the onDispose()
event and is shutdown. But if no one joins it, it stays iddle with no limit.
Is there a way to set a timeout
if nothing is made on the room after a given time? I've checked the documentation with no luck.
Thanks a lot!
Destroy a room after a set duration if no one joined it (sovled)
Hi @LouisonDVC, I think you're looking for autoDispose=false
: https://docs.colyseus.io/colyseus/server/room/#autodispose-boolean
I suggest resetting a timeout yourself to dispose the room after 1h during onCreate()
and every onLeave()
. You can use this.disconnect()
to forcibly disconnect & dispose the room when that timeout gets executed.
Hope this helps, cheers!