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 involved in implementing player invites in your game. For more information, be sure to review the pages in the See also (PlayFab) and See also (GDK) sections.
Implement player invites and joins by using the Microsoft Azure PlayFab Lobby feature
Inviting a player into a game by using PlayFab APIs and services involves a more flexible approach compared to platform-specific APIs, because PlayFab focuses on back-end logic.
For invites and joins, ensure that you've integrated the PlayFab Lobby construct.
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 PlayFab before they use features that rely on these services in your games.
Choose a lobby type:
- By players: This creates a client-owned lobby. The local player becomes the lobby owner. Use the PFMultiplayerCreateAndJoinLobby function to create this lobby.
- By your game servers: This creates a server-owned lobby. Use the PFMultiplayerCreateAndClaimServerLobby function to create this lobby.
- By matchmaking: This is created by a group of players that is formed after matchmaking. This also creates a client-owned lobby.
These lobbies serve as the game session that players can join.
Implement event handling to receive notifications about invites.
- Use PFMultiplayerStartListeningForLobbyInvites on the invite recipient to enable receiving in-game invites.
- Use the PFLobbyInviteReceivedStateChange event to handle incoming invites.
Join lobbies: players can join lobbies by providing the PlayFab Lobby service with a lobby's connection string, an opaque identifier that grants membership to the lobby. Players can join lobbies in the following ways.
- Use in-game invites: A member of a lobby can invite another player to that lobby directly via the PlayFab Lobby service. This shares the lobby's connection string with the invited player. These invites work cross-platform but only work in-game. For more information, see Lobby invites.
- Use platform-provided 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.
- Use the PFLobbySendInvite function to send an invite to another PlayFab user via the PlayFab Lobby service. This function requires the lobby handle, the sender's entity key, and the receiver's entity key.
- Search for available lobbies by using FindLobbies and join an available lobby.
- Share the lobby's connection string via any out-of-band, custom discovery mechanism.
When a player receives a connection string, they can join the lobby by using the PFMultiplayerJoinLobby function. This function requires the lobby connection string and the player's entity key.
Manage lobby state: use the PFLobbyUpdatedStateChange function to manage the lobby state, including adding or removing players, updating lobby properties, and handling player readiness.
Manage lobby events: implement event handling to receive notifications about lobby state changes. Use the PFMultiplayerStartProcessingLobbyStateChanges function and PFLobbyStateChange event to manage changes in the lobby, such as players joining or leaving.
See also (PlayFab)
The PlayFab documentation is the best source of information. Use it as a primary source. For details see the following articles.
Implement player invites and joins by using Multiplayer Activity
Inviting a player into a game by using the Microsoft Game Development Kit (GDK) Multiplayer Activity (MPA) APIs and Xbox services involves a multistep process using various API functions.
- Initialize Xbox services: ensure that Xbox services are properly initialized within your game. This involves setting up the necessary Xbox services context.
- Get the local user's Xbox User ID (
XUID
): use the XUserGetId function to retrieve theXUID
of the local player who is initiating the invite. ThisXUID
is essential for identifying the inviter. - Identify the target users: determine the
XUID
s of the players you want to invite. This can be done through the Xbox friends list, recent players list, or other ways. - Create a multiplayer activity: use the XblMultiplayerActivitySetActivityAsync function to create a multiplayer activity. This activity enables other players to see the player's activity and join the game in progress. For specific information about creating a multiplayer activity, see Activities.
- Send invites: use XblMultiplayerActivitySendInvitesAsync to send invites to other players, requesting that they join the multiplayer experience.
- Update the activity: use XblMultiplayerActivitySetActivityAsync to update the information as the activity properties change.
- Retrieve activities: use XblMultiplayerActivityGetActivityAsync to retrieve the activities of other players, displaying their activities in the in-game UI.
- Manage recent players: use XblMultiplayerActivityUpdateRecentPlayers to update the player's recent players list with any players that they've had meaningful interactions with.
- Delete the activity: when the player ends or leaves the multiplayer experience, delete the activity by using XblMultiplayerActivityDeleteActivityAsync.
Note
The connectionString
property is important when working with MPA lobby and invite solutions. This string serves as a unique identifier that contains essential information required for one player to connect to another. This string is created and understood only by the title, often containing details like server IP addresses, but it's left freeform to allow titles flexibility.
When a player starts or joins a multiplayer experience, connectionString
is passed to the activity in the XblMultiplayerActivityInfo structure. It's passed as a parameter to XblMultiplayerActivitySetActivityAsync. This enables other players to join the game in progress. This property is also included in invites, allowing players to connect seamlessly. The connectionString
ensures that players can join the correct session and facilitates smooth transitions between different multiplayer activities.
See also (GDK)
The GDK documentation is the best source of up-to-date information. For details, see the following articles and samples.
Send a request for another player to join a multiplayer experience.
-
This is a simple multiplayer game that shows how to use the Microsoft Azure PlayFab Party and Multiplayer C++ SDKs and APIs in games.
-
This sample shows how to use the MPA for activities and invites.