Store stream data / Lobby Implementation


Currently I’m trying to implement a lobby mechanism for our game on top of streams. What I’m trying to achieve is:

  • Create Lobbys that users can join or leave
  • Anyone in a Lobby can create/start a match, but only one match can be active within a Lobby
  • Users joining a Lobby, that has an ongoing match should get some information about the ongoing game (e.g. state & matchID)

My current implementation for the lobby is based upon streams. Each lobby is a stream that users can join or leave. A user starting a game broadcasts the created matchID and current state to all Lobby users.

But my question is: What would be the best approach to let new users know about the current state of the lobby. Am I somehow able to store a state of a stream on the server side? Or should a client from within the stream rebroadcast the current state, once a new user joins the stream?

Thanks in advance for your help!

@fabifink You have two options I think:

  1. Designate one of your lobby members as “leader” and make them responsible for sending any required data to lobby members as needed by your logic.
  2. Create an authoritative match handler to govern lobbies.

Option (2) would be my preference since you can use match state on the server to manage the data and send it to users as needed, or run more complex logic that shouldn’t live in the client. Match join/leave hooks is what you’d use to decide when data needs to be sent and to which users.

If you already use authoritative matches for gameplay and go with option (2) for lobbies, make sure your match labels contain a “type” fiend of some sort so you can distinguish between lobby and gameplay matches.

1 Like

Thanks for pointing out those two options and sorry for my late reply.

Currently I’m sticking with my initial approach based on sockets, as I was able to refactor the logic without the need to send updates from the client. But I might move to your approach with the authoritative match, once I need more functionality within my lobby!

No problem, keep in mind the option if you need it. A match doesn’t necessarily need to power gameplay - it’s any realtime interaction between clients backed by server-side logic. :+1: