Steps to send and accept an invite
The following steps use Multiplayer Manager to send an invite to a user’s friend so that friend can join a game in progress.- Initialize Multiplayer Manager
- Create the lobby session by adding local users
- Send invites to friends
- Accept invites
- Join a game session from the lobby
Initialize Multiplayer Manager
The lobby session object is automatically created when Multiplayer Manager is initialized with a valid session template name. Session templates are defined in the service configuration.The lobby session instance on the service isn’t created until a user has been added.
Flat C API
Create the lobby session by adding local users
Add the locally signed-in XBOX services users to the lobby session. A new lobby is hosted when the first user is added. All other users are added to the existing lobby as secondary users. Multiplayer Manager advertises the lobby in the shell for friends to join. You can send invites, set lobby properties, and access lobby members vialobby() only after you’ve added the local user.
When a local user joins the lobby, we recommend setting their connection address and any custom properties.
You must repeat this process for all locally signed-in users.
Return to the top of this topic.
Add a single local user
Flat C API
- XblMultiplayerManagerLobbySessionAddLocalUser
- XblMultiplayerManagerLobbySessionSetLocalMemberConnectionAddress
- XblMultiplayerManagerLobbySessionSetProperties
Add multiple local users
Flat C API
- XblMultiplayerManagerLobbySessionAddLocalUser
- XblMultiplayerManagerLobbySessionSetLocalMemberConnectionAddress
- XblMultiplayerManagerLobbySessionSetProperties
- Register Real-Time Activity and multiplayer subscriptions with the XBOX services multiplayer service.
- Create the lobby session.
- Join all local players as active.
- Upload the secure device address (SDA).
- Set member properties.
- Register for session change events.
- Set the lobby session as an active session.
Send invites to friends
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. Games can also use the XblMultiplayerManagerLobbySessionInviteUsers method to send invites to a set of people who are defined by their XBOX services User IDs. This method is useful if you use your own in-game UI instead of the standard XBOX UI.Flat C API
- Displays the XBOX standard title-callable UI (TCUI)
- Sends an invite directly to the selected players
Accept invites
When an invited player accepts a game invite or joins a friend’s game via a shell UI, the game is launched on their device. On Microsoft Game Development Kit (GDK)-based games, after the game starts, listen to invite events by calling XGameActivationRegisterForEvent. On XBOX One Software Development Kit and Universal Windows Platform (UWP)-based games, after the game starts, Multiplayer Manager can use the protocol-activated event arguments to join the lobby. If the invited user isn’t added via XblMultiplayerManagerLobbySessionAddLocalUser, XblMultiplayerManagerJoinLobby will fail and provide the xuid for which the invite was sent by calling XblMultiplayerEventArgsXuid with theJoinLobbyCompleted event.
After joining the lobby, we recommend setting the local member’s connection address and any custom properties for the member.
You can also set the host via XblMultiplayerManagerLobbySessionSetSynchronizedHost if one doesn’t exist.
Finally, Multiplayer Manager auto-joins the user into the game session, if a game is already in progress and has room for the invitee.
The title is notified through the JoinGameCompleted event, providing an appropriate error code and message.
Error or success results are handled via the JoinLobbyCompleted event.
Flat C API
- Register Real-Time Activity and multiplayer subscriptions.
- Join lobby session.
- Existing lobby state cleanup.
- Join all local players as active.
- Upload the SDA.
- Set member properties.
- Register for session change events.
- Set lobby session as the active session.
- Join game session (if one exists).
- Use a transfer handle.
Join a game session from the lobby
After invites have been accepted, and the host is ready to start playing the game, you can start a new game that includes the members of the lobby session by calling XblMultiplayerManagerJoinGameFromLobby. Error or success results are handled via theJoinGameCompleted event.
Flat C API
- Create game session.
- Join all local players as active.
- Upload the SDA.
- Set member properties.
- Register for session change events.
- Advertise game via lobby session.
