Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Best Practices for Lobby with Game Server Hosting

Discussion in 'Lobby' started by theMatan123, Jun 14, 2023.

  1. theMatan123

    theMatan123

    Joined:
    Feb 6, 2023
    Posts:
    3
    I have been using Unity Game Server Hosting for my game for a month or so now and have begun adding a Lobby integration. I currently have it so that players can join each other's lobbies and my next step is letting the players jointly connect to a Game Server.

    Prior to adding Lobby, I have to manually spin up servers and/or expose functionality for allocating new servers to the clients (which is not ideal).

    My question is what is the best practice for using Lobby with an online game server?

    My original idea was that when all players in the Lobby are ready, the host queues an allocation request using the web API. Lobby-scoped data could be used to share the ip of the game server amongst the players once the allocation was successful.

    However, I'm unsure what happens in certain edge cases. For instance, if players disconnect from the lobby while the allocation is going through, will this leave a game server waiting perpetually? This could be solved by first checking if servers are already allocated and connecting to an existing allocation, but this could introduce race conditions between different lobbies.

    Is this the recommended way to use Lobby with Unity Game Server Hosting?
     
  2. JonLandmark

    JonLandmark

    Joined:
    Jan 15, 2022
    Posts:
    5
    Hi, did you find a solution to your issue? We are currently implementing the same setup and have the same concern of a host disconnecting mid-allocation being assigned.
     
  3. theMatan123

    theMatan123

    Joined:
    Feb 6, 2023
    Posts:
    3
    The solution I arrived at was to have Game Servers shut themselves down after 30 seconds of being allocated with nobody joining, that way they can be reallocated.

    I still haven’t perfectly solved some of the edge cases but this at least ensures that I don’t continue to allocate new servers unnecessarily.