-
Is there a way to get the list of available rooms live without calling getAvailableRooms at some interval? I did not find anything in the documentation( My other thoughts were to get a socket instance from Colyseus and send a socket message when the room is created and deleted Example:
But I get such error So the next question is, can I just connect to the socket without using Colyseus client? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I have one more crazy idea. XD. I can create a separate room that will be responsible for the available rooms. This room has a state with available rooms. Other rooms change the state of this specific room. And client has a sync callback when rooms change |
Beta Was this translation helpful? Give feedback.
HI @bedryck, that is essentially what the
LobbyRoom
does :) though, it doesn't use the state - it only sends data as the rooms become available or unavailable. You can take a look at the sources here: https://github.com/colyseus/colyseus/blob/master/packages/core/src/rooms/LobbyRoom.tsThe
LobbyRoom
uses the (yet undocumented)subscribeLobby
method, which is a "global" subscription for when rooms are available/unavailable.