Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Poker no-private lobby

Discussion in 'Lobby' started by Micka_RedRare, Dec 6, 2023.

  1. Micka_RedRare

    Micka_RedRare

    Joined:
    Mar 18, 2021
    Posts:
    14
    Hello, I need some advice for a project I'm working on.

    My team and I are creating a poker-type casino game for mobile. We're using most of the Unity Gaming Services (authentication, lobby, relay, matchmaker, friends...). Everything's fine, and multiplayer with private rooms works well.
    However, we're stuck on creating a more random mode, where anyone can join or leave an online game without the room closing if the host quit.
    We can't see how to do it properly, either to have an automatic host transfer when the host leaves the game, or to have a "virtual host" that keeps a room open as long as there are players in the room.
    I've found some info on host migration, but I don't know if this is the right solution.

    Could someone guide us on the right way to proceed please?
     
  2. mcanfield_unity

    mcanfield_unity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    13
    You are correct that host migration is certainly an option to keep a Lobby up and running when the owner leaves as detailed here: https://docs.unity.com/ugs/manual/lobby/manual/host-migration. However, if you're replicating state with something like NGO then this Lobby host migration is not going to solve your game state issue. If you're storing game state elsewhere and just using Relay for communication then upon Lobby host disconnect the players will still be in the Lobby, but a new Relay needs allocating and then players can reconnect. You'll then need to manage the "resynchronization" of state from the authoritative source.

    If you are looking for even tighter control over the Lobby lifecycle you could consider using service accounts to manage your lobbies, that way you don't need to rely on a player game client flow. https://services.docs.unity.com/docs/service-account-auth/ That would require you to run some server authoritative logic somewhere or you could look into leveraging Unity Cloud Code https://docs.unity.com/ugs/en-us/manual/cloud-code/manual. I believe the service token in that context works for Lobby https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/modules/how-to-guides/token-support. If not, there is a token exchange flow that can be used to get the correct authentication https://services.docs.unity.com/doc.../#authenticate-an-api-using-a-stateless-token . Cloud Code can also access Cloud Save from which you could potentially manage your server authoritative game state for something like poker or other card games https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/game-state-management.
     
    Micka_RedRare likes this.
  3. Micka_RedRare

    Micka_RedRare

    Joined:
    Mar 18, 2021
    Posts:
    14
    Thank you very much @mcanfield_unity for your answer. We will try all these solutions. I'll be back to give you an update after we've tried them.
     
  4. mcanfield_unity

    mcanfield_unity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    13
  5. Micka_RedRare

    Micka_RedRare

    Joined:
    Mar 18, 2021
    Posts:
    14