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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Question How to notify the Lobby when Game Server is allocated and ready?

Discussion in 'Game Server Hosting' started by mpkaerager, May 12, 2023.

  1. mpkaerager


    May 11, 2022
    I'm building my multiplayer functionality with Lobby Service and Game Server Hosting. I'm not using Matchmaker since Lobby filtering is enough for my use case. Also I'm not using Relay since my game is long-lived and needs a server throughput the game.

    Here's a brief description of my flow:

    1. A player creates a Lobby with some config (maps, game mode, max players etc)
    2. Some players join that Lobby
    3. Lobby is full and the host starts the game
    4. The host use the REST API to queue an allocation request
    5. The server is allocated and via the payload I can prepare the game session (on the server)
    6. The game session is successfully prepared and I set the server ready to accept players (on the server)
    7. My problem: how can I notify the players in the Lobby from the server?

    I've tried:
    - Update the Lobby via Cloud Code. Server is not authenticated as a player, so not possible - I could authenticated as anonymous, but I don't like that.
    - Join the lobby (as server) and update the Lobby data. Again server is not authenticated as a player, so not possible. Ideally the server should not join as a player.

    I do have a game state saved on my backend and I could update that state with server config/allocation ID, and have the client poll the game state, but it feels wrong IMO.

    Any advice is valuable.
  2. unityacc275


    Mar 29, 2023
    not sure if you get the ip and port from the allocation but if you do get those, you could on the server side open the UDP connection after server is ready to receive players

    and on the cleint , as soon as you have the ip/port start connecting, basicly using the timeout mechanic of the UDP connector

    when connected , the server was ready to receive players , when timeoud you could try again or fallback