Lobby system with AWS gamelift and gamelift nakama plugin

Questions about approaches to implement a lobby system with nakama and aws gamelift

Hi Team,
We are trying to implement a multiplayer game experience using nakama and aws gamelift, Currently we are going with automated matchmaking for our POC(where a user clicks on find match and gets matched with people based on appropriate heuristics) for which the implementation is straight forward based on this documentation(GameLift Fleet Management - Heroic Labs Documentation)
Our road map might include a pivot to lobby based matchmaking and there is no appropriate documentation on how to achieve this with aws gamelift asfaik. So im chalking out a way to achieve this which i think is feasible below in the details section, i would request you to review this and provide guidance, best practices and pitfalls based on the same. I’m seeking your expertise so we can put this in roadmap and structure our current code better for easy portability. If this chalked out approach is wrong/ a bad practice, please guide me on how to achieve what i indented to do.

{Details}

User Request Flow for Lobby matchmaking using Nakama and AWS gamelift plugin

  1. Player A creates a lobby match which hits a custom api registered in nakama and returns a unique lobby code, Player A receives the lobby code in Screen, lets say the lobby code is xYa132.
  2. Player A shares this code with his friends, Player B and Player C.
  3. Player A then starts the match and the client sends the query with the lobby code with matchmaker_add socket message envelope along with the query, from the nakama gamelift documentation the query will look like query := “+value.lobbyCode:xYa132”, the player A gets a session created and receives ip address, dns etc etc and waits in the lobby match.
  4. Player B and Player C paste the lobbyCode and clicks Join Match and they have matchmaker_add socket message envelope created with query “+value.lobbyCode:xYa132”, they get matched with this unique query and get same ip address and dns as player A and then they connect and play the match.
    Is this a feasible way to approach lobby based matchmaking with nakama and aws gamelift ? any pitfalls ? any best practices ?
    Thanks and Regards
    Harish Kumar Datla

:tv: Media:

Hi @harishkumar,

If you’re doing an invite flow to a lobby, you shouldn’t need to use matchmaker_add at all, a rough sequence of steps would be:

  1. Player A creates the lobby match via a custom RPC that internally calls FleetManager Create.
  2. Player A can use the Create callback to be notified of when the match is ready.
  3. Player A sends InstanceInfo to Player B and C via notification, party or chat.
  4. Player B and C call Join, where the id param is the InstanceInfo id.
  5. Player B and C connect to the GameLift instance using SessionInfo received via Join().

If userId is set in the Create call, then the callback will receive a SessionInfo that player A can use to connect to the instance directly, otherwise he’ll have to call Join to receive the InstanceInfo as well.

Alternatively, if Player A, B and C are already in a Party, the Party Leader could call Create with all 3 userIds set in the Create call, get back the 3 SessionIds, use his own to connect and relay the other 2 to the corresponding players.

There’s other combinations of steps, but this is a rough outline. The important thing here is that Nakama doesn’t know of GameLift instances which haven’t fully initialized and they register themselves by calling the Update RPC.

If you’d like other players to be able to list lobbies they can join, you can expose a custom RPC that calls the FleetManager List() function to search for lobbies that aren’t full.

You can use the Create metadata field to pass optional key GameProperties, and a map[string]string as a value, to pass key value pairs that will be accessible from both the GameLift instance via the SDK and can also be queries using List via the query param (could be useful to have Public vs Private lobbies/matches, for example).

Hope this clarifies.

1 Like