XGameInviteEventCallback
A callback an application defines for a game invite event.
Syntax
void XGameInviteEventCallback(
void* context,
const char* inviteUri
)
Parameters
context _In_opt_
Type: void*
The context we pass to XGameInviteRegisterForEvent.
inviteUri _In_
Type: char*
The URI for joining the game session.
Note
XSAPI knows how to consume the URI.
Return value
Type: void
Remarks
To register a callback for a game invite event, call XGameInviteRegisterForEvent. The function uses a pointer to an XGameInviteEventCallback as an argument.
To un-register a callback for a game invite event, call XGameInviteUnregisterForEvent.
The following code sample registers for a game invite callback.
#include <XTaskQueue.h>
#include <XGameInvite.h>
XTaskQueueHandle g_taskQueue;
XTaskQueueRegistrationToken g_gameInviteEventToken;
void OnGameInvite(void* context, const char* inviteUri)
{
if (inviteUri != nullptr)
{
std::string inviteString(inviteUri);
auto pos = inviteString.find("handle=");
auto inviteHandeId = inviteString.substr(pos + 7, 36);
// Now call XblMultiplayerManagerJoinLobby if using MPM
// or call XblMultiplayerWriteSessionByHandleAsync if using MPSD APIs
}
}
void InitializeGame()
{
XGameInviteRegisterForEvent(g_taskQueue, nullptr, OnGameInvite, &g_gameInviteEventToken);
}
void ShutdownGame()
{
XGameInviteUnregisterForEvent(g_gameInviteEventToken);
}
Requirements
Header: XGameInvite.h
Library: xgameruntime.lib
Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles