Poker no-private lobby

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?

You are correct that host migration is certainly an option to keep a Lobby up and running when the owner leaves as detailed here: 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. Admin authentication | Unity Services Web API docs That would require you to run some server authoritative logic somewhere or you could look into leveraging Unity Cloud Code Cloud Code. I believe the service token in that context works for Lobby Service and access token support. If not, there is a token exchange flow that can be used to get the correct authentication Admin authentication | Unity Services Web API docs . 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 Game state management.

1 Like

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.

Sure, no problem. If you’re going to look into Cloud Code here is the api for their usage of Lobby –

https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/scripts/use-cases/lobby

1 Like

Thanks

Hmm… If you want to keep the game running smoothly even if the host leaves, a “virtual host” might be the way to go. This would mean having something on the server side that keeps the room open as long as there are players in it, so the game doesn’t depend on one person’s connection.
If you’re building a poker game, it might be worth looking into Online poker site where you can play for free. They actually could give you some ideas on how to keep your game running without interruptions and make sure players can come and go without any issues.

Cloud Code could hold things down by managing the room on its own, so it doesn’t depend on any single player staying connected. I’d also look into Cloud Save to store the game state — that way, if a player reconnects, they pick up right where they left off, no sweat.
Honestly, it’s kind of like how online poker rooms work, where players can hop in and out without messing up the flow. Slot77 has a setup that’s worth checking out to see how they keep the game rolling no matter who joins or leaves.