Share via


Implement lobbies in your game

This article provides a summary of the steps to implement lobbies in your game. For detailed information, be sure to review the articles in the See also section at the end of this article.

Implement game lobbies by using Microsoft Azure PlayFab Lobby

Implementing game lobbies by using Microsoft Azure PlayFab APIs and services can be approached in several ways. The recommended method is to use the PlayFab Lobby API. Use the following steps to implement a game lobby.

  1. Download and set up the Azure PlayFab Lobby and Matchmaking SDK: setup the C/C++ SDK for your platform, and then integrate the provider header and library files into your build.
  2. Authenticate the player: players must be authenticated with both Xbox services and PlayFab before they use features that rely on these services in your games.
  3. Initialize the PlayFab SDK: initialize the SDK by calling PFMultiplayerInitialize. Set the entity key and token used by the library on behalf of your players by calling PFMultiplayerSetEntityToken.
  4. Create a lobby.
    1. Call PFMultiplayerCreateAndJoinLobby.
    2. Check for asynchronous completion by periodically polling PFMultiplayerStartProcessingLobbyStateChanges for PFLobbyCreateAndJoinLobbyCompletedStateChange.
  5. Join a lobby by using in-game invites.
    • A member of a lobby can invite another player to that lobby directly via the lobby service.
    • This invite shares the lobby's connection string with the invited player.
    • The invited player receives the invitation via PFLobbyInviteReceivedStateChange and can use the attached connection string to join the lobby.
    • These invites work cross-platform but only work in-game.
  6. Join a lobby by using platform invites.
    • Members of the lobby can directly share the lobby's connection string with other players over platform-specific invite mechanisms.
    • These invites don't work cross-platform but can be received without the recipient already playing the game.
    • After the invited player receives the connection string via the platform mechanism, they can use the attached connection string to join the lobby.
  7. Integrate with Matchmaking.
    • PlayFab Lobby and Matchmaking work seamlessly together to create a cohesive multiplayer matchmaking experience for your game.
    • Matchmaking gathers a set of players together who want to participate in a game session.
    • After matchmaking has identified a set of players, PlayFab Lobby provides them with a communication medium to coordinate joining a game session together.
  8. Find a lobby: use FindLobbies and the filter parameter to restrict your query to return only search results that match some set of criteria based on the lobby's custom search properties.

Integrating PlayFab Lobby and Matchmaking with the Microsoft Game Development Kit Multiplayer Activity

Multiplayer Activity (MPA) is a lightweight service to simplify Xbox services. To integrate MPA with PlayFab Lobby and Matchmaking or similar services, a game or game service must query the relevant information from the lobby state and then migrate this information into the MPA service. It's not intended for lobby or session state information.

For more information, see Integration with PlayFab Lobby & Match.

In addition, to use Xbox services, the player must also be signed in with their Xbox account. For more information see Implement player sign in in your game.

See also

The PlayFab documentation is the best source of up-to-date information. For details, see the following articles and samples.