Sending game invites using Multiplayer Manager
In a simple multiplayer scenario, a player of your game can play it online with friends. This topic describes the steps for sending invites to another player to join your game.
Initialize Multiplayer Manager and create a lobby session by adding local users. For more information, see Enable playing a multiplayer game with friends by using Multiplayer Manager.
After you receive the XblMultiplayerEventType::UserAdded
event, you can start sending invites.
An invite can be sent in two ways.
For more information about the process, see Sending invites to another player (flowchart).
Xbox platform invite TCUI
Call XblMultiplayerManagerLobbySessionInviteFriends to display the standard Xbox UI where the player can select friends or recent players to invite to the game. When the player confirms their selection, Multiplayer Manager sends the invites to the selected players.
Flat C API
std::string customActivationContext = "{ \"customGameData\": 1 }"; // This string can be anything your game sends across to the invited player's game.
HRESULT hr = XblMultiplayerManagerLobbySessionInviteFriends(xuserHandle, nullptr, customActivationContext.c_str());
Multiplayer Manager performs the following functions to invite players by using the Xbox platform invite TCUI.
- Displays the Xbox standard TCUI.
- Sends invite directly to the selected players.
Title-implemented custom UI
Your title can implement a custom TCUI for viewing online friends and inviting them. Games can use the XblMultiplayerManagerLobbySessionInviteUsers method to send invites to a set of people defined by their Xbox Live User IDs. This is useful if you use your own in-game UI instead of the standard Xbox UI.
Flat C API
size_t xuidsCount = 1;
uint64_t xuids[1] = {};
xuids[0] = 1234567891234567;
HRESULT hr = XblMultiplayerManagerLobbySessionInviteUsers(
xblUserHandle,
xuids,
xuidsCount,
nullptr, // ContextStringId
nullptr // CustomActivationContext
);
When using a title-implemented custom UI, Multiplayer Manager sends an invite directly to selected players.