Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article provides a summary of the steps to implement matchmaking in your game. For detailed information, be sure to review the articles in the See also section at the end of this article.
Implement Matchmaking by using the Microsoft Azure PlayFab Lobby and Matchmaking SDK
The layFab Lobby and Matchmaking SDK is now part of the GDK.
- Download and set up the Azure PlayFab Lobby and Matchmaking SDK: download the C/C++ SDK for your platform, and then integrate the provider header and library files into your build.
- Authenticate the player: players must be authenticated with both Xbox services and Microsoft Azure PlayFab before using features that rely on these services in your games.
- Initialize the PlayFab Multiplayer 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.
- Configure matchmaking queues: match configuration centers around queues, which represent a place where tickets wait to be matched with each other. Each queue has some general configuration information about what's required for a match. In addition, a queue can contain a set of rules that provide further restrictions on how tickets are matched together. For specific information, see Configuring matchmaking queues.
- Create a matchmaking ticket: create a matchmaking ticket by using PFMultiplayerCreateMatchmakingTicket. Specify all local players that want to be part of the match and any attributes you want associated with those players. There are three different scenarios for creating a matchmaking ticket:
- Implement matchmaking with a single local player: call
PFMultiplayerCreateMatchmakingTicket
with a singlePFEntityKey
to start matchmaking for a single local player. - Implement matchmaking with a group of remote players.
- The leader creates the ticket by using
PFMultiplayerCreateMatchmakingTicket
. It specifies the other players in the group through the configuration parameter. - Call PFMatchmakingTicketGetTicketId to get the ticket ID.
- Send this ID to each other player by using an external mechanism, such as a networking mesh or a shared PlayFab Lobby. Have each client call PFMultiplayerJoinMatchmakingTicketFromId with the ticket ID to join the matchmaking ticket.
- The ticket status will be PFMatchmakingTicketStatus::WaitingForPlayers while waiting for the specified players to join. The status changes to
PFMatchmakingTicketStatus::WaitingForMatch
after all the players have joined the ticket.
- The leader creates the ticket by using
- Implement matchmaking with multiple local players.
- Pass a list of
PFEntityKey
and a corresponding list of attributes for each player to thePFMultiplayerCreateMatchmakingTicket
orPFMultiplayerJoinMatchmakingTicketFromId
functions. - Ensure each list entry position matches, so that the first entry in the attributes list corresponds to the first player in the PFEntityKey list.
- Pass a list of
- Implement matchmaking with a single local player: call
- Check the status of the matchmaking ticket: check for updates to the ticket by calling PFMultiplayerStartProcessingMatchmakingStateChanges to receive state changes. Call PFMultiplayerFinishProcessingMatchmakingStateChanges when you're done processing those state changes. The SDK returns a
TicketStatusChanged
state change whenever the status of the ticket changes and aTicketCompleted
state change when matchmaking is done. - Get the match: after receiving the PFMatchmakingStateChangeType::TicketCompleted state change, call PFMatchmakingTicketGetMatch to get the details of the match.
- Get the information you need out of the PFMatchmakingMatchDetails struct. Destroy the ticket by using PFMultiplayerDestroyMatchmakingTicket.
- Cancel a matchmaking ticket: to cancel the matchmaking process prior to the timeout set in the PFMatchmakingTicketConfiguration, call PFMatchmakingTicketCancel with the ticket handle.
- Connecting your players together into a lobby (optional): after the players have matched, they can join up together in a lobby. The PFMatchmakingMatchDetails from the matched ticket contains a
lobbyArrangementString
field, which can be used to join the players into the same lobby. This allows integration between the features. If you have your own technology, you can use it. - Allocating server functionality (optional): matchmaking includes an option that can automatically create a game server for the resulting match. The allocated server runs a build, which is configured in the queue's configuration file. On startup, the server is passed in the members of the match as the list of initial players. A matchmaking queue is tied to a single multiplayer server build or to a build alias. For specific information, see Integrating with PlayFab Multiplayer Servers.
See also
The PlayFab documentation is the best source of up-to-date information. For details, see the following articles and sample.
-
This is a simple multiplayer game that shows how to use the Microsoft Azure PlayFab Party and Multiplayer C++ SDKs and APIs in games.