> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 招待の送信

> Title-Callable UI オーバーレイ、または XblMultiplayerSendInvitesAsync API とカスタムのゲーム内 UI を使用して、タイトルから XBOX マルチプレイヤー ゲーム招待を送信します。

このトピックでは、XBOX services 上でユーザー間マルチプレイヤー ゲーム セッションを構成する方法について説明します。

ゲームは、ゲーム セッションに参加するように他のユーザーに招待を送信します。他のユーザーにゲーム招待を送信する方法は 2 つあります。
Title-Callable UI (TCUI) (システム UI オーバーレイ) を使用するか、タイトルで実装されたカスタム UI を使用できます。

## Title-Callable UI (TCUI) (システム UI オーバーレイ) の使用

[XGameUiShowSendGameInviteAsync](/reference/system/xgameui/functions/xgameuishowsendgameinviteasync) API を呼び出すと、フレンドを招待するための標準のシステム UI オーバーレイが取得されます。
これにより、ユーザーが移動してフレンドや [直近のプレイヤー一覧](/services/xbox-services/multiplayer/mpa/concepts/live-mpa-recent-players) からユーザーを選択してゲームに招待できる UI が表示されます。ユーザーが **\[確認]** を選択すると、選択したユーザーに招待が送信されます。

## タイトルで実装されたカスタム UI の使用

タイトルは、オンライン フレンドを表示し、ゲーム セッションに招待するためのカスタム UI を実装できます。
[XblMultiplayerSendInvitesAsync](/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersendinvitesasync) API を使用して、次のコードのように、[XboxUserId (XUID)](/services/xbox-services/multiplayer/mpa/concepts/live-mpa-activities) で定義される一連のユーザーに招待を送信します。
これは、標準のシステム UI ではなく独自のゲーム内 UI を使用したい場合に便利です。

### Flat C

```cpp theme={null}
auto asyncBlock = std::make_unique<XAsyncBlock>();
asyncBlock->queue = queue;
asyncBlock->context = nullptr;
asyncBlock->callback = [](XAsyncBlock* asyncBlock)
{
    std::unique_ptr<XAsyncBlock> asyncBlockPtr{ asyncBlock }; // Take ownership of the XAsyncBlock*
    size_t handlesCount = 1; // must be equal to invites that are requested
    XblMultiplayerInviteHandle handles[1] = {};
    HRESULT hr = XblMultiplayerSendInvitesResult(asyncBlock, handlesCount, handles);
};

uint64_t xuids[1] = {};
xuids[0] = targetXuid;
size_t xuidsCount = 1;

HRESULT hr = XblMultiplayerSendInvitesAsync(
    xblContextHandle,
    &sessionReference,
    xuids,
    xuidsCount,
    titleId,
    contextStringId,
    customActivationContext,
    asyncBlock.get());
if (SUCCEEDED(hr))
{
    // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take ownership.
    // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
    asyncBlock.release();
}
```

## リファレンス API ドキュメント

* [Xgameactivation (API contents)](/reference/system/xgameactivation/xgameactivation_members)
* [xgameui (API contents)](/reference/system/xgameui/xgameui_members)
  * 関数
    * [XGameUiShowSendGameInviteAsync](/reference/system/xgameui/functions/xgameuishowsendgameinviteasync)
* [multiplayer\_c (API contents)](/reference/live/xsapi-c/multiplayer_c/multiplayer_c_members)
  * 関数
    * [XblMultiplayerSendInvitesAsync](/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersendinvitesasync)
    * [XblMultiplayerSendInvitesResult](/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersendinvitesresult)
  * 構造体
    * [XblMultiplayerInviteHandle](/reference/live/xsapi-c/multiplayer_c/structs/xblmultiplayerinvitehandle)
* [xasync (API contents)](/reference/system/xasync/xasync_members)
  * 構造体
    * [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)

## 関連項目

[XAsyncBlock](/reference/system/xasync/structs/xasyncblock)
[XblMultiplayerInviteHandle](/reference/live/xsapi-c/multiplayer_c/structs/xblmultiplayerinvitehandle)
[XblMultiplayerSendInvitesAsync](/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersendinvitesasync)
[XblMultiplayerSendInvitesResult](/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersendinvitesresult)
[XGameActivation (API リファレンス)](/reference/system/xgameactivation/xgameactivation_members)
[Multiplayer Manager を使用したゲーム起動のプロトコル アクティベーションの処理](/services/xbox-services/multiplayer/mpm/how-to/live-handle-protocol-activation)
[Multiplayer Manager を使用したゲーム招待の送信](/services/xbox-services/multiplayer/mpm/how-to/live-send-game-invites)


## Related topics

- [招待の概要](/ja-jp/services/xbox-services/multiplayer/invites/live-multiplayer-invites-overview.md)
- [招待の例コード](/ja-jp/services/xbox-services/multiplayer/invites/how-to/live-invites-howto-nav.md)
- [プレイヤーをゲーム セッションに招待する](/ja-jp/services/xbox-services/multiplayer/invites/live-invites-nav.md)
- [ロビーの招待](/ja-jp/services/playfab/multiplayer/lobby/lobby-invites.md)
- [XblMultiplayerInviteHandle](/ja-jp/reference/live/xsapi-c/multiplayer_c/structs/xblmultiplayerinvitehandle.md)
