Picking a Room based on onAuth data

Hi guys,

I have this use case where the players get their current location from the onAuth method. Each map in my game has its own Room to connect to. For now I created MapRoom and TownRoom, the problem is the client doesn't know which one to connect to. So I figured maybe create a third Room called LobbyRoom and let all clients connect to that first, get the location data and send it to the client so the client connect to the correct room. Is this even safe? I don't want the client to be able to connect to any Room they want. Is this even a good practice? Or maybe it is possible to initiate TownRoom from LobbyRoom without sending a message to the client to reconnect (haven't found such options).

Any thoughts on this?

Thanks in advance!

Hi @rbjs92, I think it would be easier for matchmaking if you have only MapRoom, and compose your objects inside it to be able to handle the Town functionality. What are the major implementation differences you have between Map and Town rooms?

Hi @endel, you are fast!!

I had it like u suggested at first.

MapRoom has MapState with

  • World (static platforms, ground etc)
  • PlayerState
  • EnemyState
  • NpcState
  • BlockState (all dynamic bodies that aren't players npcs or enemies)

The player in TownRoom doesn't need to know about the state from MapRoom so I thought to create a room for each map to make the game as lightweight as possible. But thinking now maybe there is a way I can get the data from onAuth and then initiate MapState or TownState based on that without sharing for example NpcState to all the players online.