> ## 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.

# XBOX 需求

> 在 XBOX 主機上使用 PlayFab Party 以符合 XBOX 需求 (XR) 的最佳做法，涵蓋聊天、隱私權、跨網路遊玩和多人遊戲工作階段。

如果您的遊戲以 XBOX 主機為目標，就必須遵守一組需求，以確保在與 XBOX Live 互動時具有一致的功能和行為。這組需求列在 [XBOX 需求](https://aka.ms/xrs) (簡稱 XR) 中。XR 與在 PC 和其他平台上的遊戲中使用 XBOX Live 所需的[原則](https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/live/get-started/live-xbl-overview)相互影響且有所重疊。這裡將說明 PlayFab Party 的最佳做法，協助您遵循這些需求。

如需快速參考，請參閱下表，其中將 PlayFab Party 案例與其所對應的 XR 進行比對：

| 案例 | XR |
| - | - |
| [讓 PlayFab Party 與 XBOX Live 使用者的聊天設定和權限保持一致](#aligning-playfab-party-with-an-xbox-live-users-chat-settings-and-privileges) | [XR-015](https://developer.microsoft.com/games/xbox/docs/gdk/xr015), [XR-045](https://developer.microsoft.com/games/xbox/docs/gdk/xr045) |
| [維護多人遊戲工作階段文件](#maintaining-a-multiplayer-session-document) | [XR-067](https://developer.microsoft.com/games/xbox/docs/gdk/xr067) |
| [識別跨網路遊戲工作階段中的玩家](#identifying-players-in-a-cross-network-game-session) | [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) |
| [遵守 XBOX Live 使用者的跨網路通訊權限](#respecting-cross-network-communication-permissions-for-xbox-live-users) | [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) |
| [在不允許跨平台遊玩時，使用 PlayFab Party 邀請限制網路存取](#use-playfab-party-invitations-to-restrict-access-to-networks-when-cross-play-is-not-allowed) | [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) |
| [與 XBOX Live 設定檔設定保持同步](#keeping-in-sync-with-xbox-live-profile-settings) | [XR-048](https://developer.microsoft.com/games/xbox/docs/gdk/xr048) |
| [支援平台多人遊戲加入流程](#supporting-platform-multiplayer-join-flows) | [XR-064](https://developer.microsoft.com/games/xbox/docs/gdk/xr064), [XR-124](https://developer.microsoft.com/games/xbox/docs/gdk/console-certification-requirements-and-tests) |
| [好友清單](#friends-lists) | [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007), [XR-070](https://developer.microsoft.com/games/xbox/docs/gdk/console-certification-requirements-and-tests) |
| [遵守 XBOX Live 服務重試原則和服務存取限制](#honoring-xbox-live-service-retry-policy-and-service-access-limitations) | [XR-074](https://developer.microsoft.com/games/xbox/docs/gdk/xr074), [XR-132](https://developer.microsoft.com/games/xbox/docs/gdk/xr132) |

## PlayFab Party XBOX Live Helper 程式庫

除了核心 PlayFab Party 程式庫之外，我們還提供 [XBOX Live Helper 程式庫](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide)，其設計目的是協助遵循 XBOX Live 原則，進而遵循 XR。使用此協助程式庫並非必要，但強烈建議使用，並被視為最佳做法。這裡提供的範例將假設您使用 XBOX Live Helper 程式庫。

<a id="aligning-playfab-party-with-an-xbox-live-users-chat-settings-and-privileges" />

## 讓 PlayFab Party 與 XBOX Live 使用者的聊天設定和權限保持一致

PlayFab Party 使用選擇加入的聊天通訊模型，且根據預設，會將兩個[聊天控制項](/zh-TW/services/playfab/multiplayer/networking/concepts-objects#chat-control)之間的所有通訊，限制為雙方參與者都已啟用的通訊集合。如需詳細資訊，請參閱[聊天權限和靜音](/zh-TW/services/playfab/community/voice-communications/concepts-chat-permissions-and-muting)的文件。

PlayFab Party 的 [XBOX Live Helper 程式庫](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide)會指出應啟用哪一組聊天權限，以符合目前在 Party 工作階段中通訊之 XBOX Live 使用者的偏好設定和權限。如需詳細資訊，請參閱關於[遵守 XBOX Live 使用者的隱私權設定和權限](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide#respecting-an-xbox-live-users-privacy-settings-and-permissions)的文件。

透過正確使用 PlayFab Party 和 [XBOX Live Helper 程式庫](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide)，您的遊戲可以完全符合 [XR-015](https://developer.microsoft.com/games/xbox/docs/gdk/xr015) 所指定的需求，並可符合 [XR-045](https://developer.microsoft.com/games/xbox/docs/gdk/xr045) 所指定的相關通訊需求。如需 PlayFab Party 範圍以外的其他需求，請參閱 [XR-045](https://developer.microsoft.com/games/xbox/docs/gdk/xr045) 技術文件。

<a id="maintaining-a-multiplayer-session-document" />

## 維護多人遊戲工作階段文件

PlayFab Party 不提供任何形式的 XBOX 使用者名冊。它依賴您的遊戲使用多人遊戲工作階段目錄服務 (MPSD) 來維護名冊，並將 Party 網路活動與遊戲工作階段中的使用者建立關聯。當遠端[端點](/zh-TW/services/playfab/multiplayer/networking/concepts-objects#endpoint)和[聊天控制項](/zh-TW/services/playfab/multiplayer/networking/concepts-objects#chat-control)進出 Party [網路](/zh-TW/services/playfab/multiplayer/networking/concepts-objects#network)時，PlayFab Party 會公告它們。與這些物件相關聯的 PlayFab 實體識別碼應與 MPSD 文件中的 XBOX 使用者進行比對，以識別哪些 PlayFab Party 物件代表遊戲工作階段中的 XBOX 使用者。在跨平台遊玩案例中，未與 XBOX 使用者相關聯的 PlayFab 實體可能代表另一個多人遊戲生態系統中的使用者。

若要識別 XBOX 使用者，您應建立 PlayFab 實體識別碼與 XBOX Live 使用者之間的對應。為此，建議您將工作階段的 XBOX Live 使用者清單儲存在 MPSD 文件中，並使用 XBOX Live Helper 程式庫將這些 XBOX Live 使用者轉譯為 PlayFab 實體識別碼。如需範例，請參閱 [XBOX Live 使用者識別碼與 PlayFab 實體識別碼之間的對應](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide#mapping-between-xbox-live-user-ids-and-playfab-entity-ids)。

除了提供 Party 網路的名冊之外，MPSD 文件也會驅動 XBOX 多人遊戲生態系統中的許多多人遊戲體驗，例如配對、平台邀請、最近玩家清單和中途加入。如需如何將 Party 網路納入這些 MPSD 流程的詳細資訊，請參閱[搭配 MPSD 使用 PlayFab Party](/zh-TW/services/playfab/multiplayer/networking/using-mpsd)。

如需詳細資訊，請參閱 [MPSD 概觀](/zh-TW/services/xbox-services/multiplayer/mpsd/live-mpsd-overview)。

<Info>
  本節提供搭配 MPSD 使用 PlayFab Party 時的最佳做法，但 PlayFab Party 本身不會隱含地滿足 [XR-067](https://developer.microsoft.com/games/xbox/docs/gdk/xr067) 的 MPSD 需求。如需滿足這些需求的資訊，請參閱 [XR-067](https://developer.microsoft.com/games/xbox/docs/gdk/xr067) 技術文件。
</Info>

## 在跨平台遊玩 Party 網路中使用 XBOX 用戶端

在跨平台遊玩案例中，與 XBOX Live 生態系統互動時，請牢記下列最佳做法。

<Info>
  本節提供在與 XBOX Live 的跨平台遊玩案例中使用 PlayFab Party 的最佳做法，但使用 PlayFab Party 不會隱含地滿足 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) 的跨平台遊玩需求。如需滿足這些需求的資訊，請參閱 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) 技術文件。
</Info>

<a id="identifying-players-in-a-cross-network-game-session" />

### 識別跨網路遊戲工作階段中的玩家

唯一的玩家應該能在不同的多人遊戲生態系統之間被識別和區分。為此，PlayFab Party 在可能與工作階段中使用者相關聯的各種物件上提供 PlayFab 實體識別碼：`PartyLocalUser`、`PartyEndpoint`、`PartyChatControl`。

PlayFab Party API 不提供跨網路顯示名稱。在 UI 中顯示 XBOX 使用者時，您應使用其玩家代號，且應從 MPSD 文件中的 XBOX 使用者識別碼解析玩家代號。非 XBOX 使用者應根據 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) 中的指導方針在 UI 中呈現。在沒有平台提供之顯示名稱的情況下，PlayFab 透過 [GetPlayerProfile](xref:titleid.playfabapi.com.client.accountmanagement.getplayerprofile) 提供顯示名稱支援。加入網路時，玩家應在共用的工作階段文件中發佈其顯示名稱，供其他玩家查看。

雖然 PlayFab Party 程式庫會將其部分物件與 PlayFab 使用者建立關聯 (透過 PlayFab 實體識別碼)，但程式庫不提供識別 PlayFab 使用者可能與哪些多人遊戲生態系統相關聯的功能。若要區分 XBOX Live PlayFab 使用者與其他多人遊戲生態系統中的使用者，建議將 Party 網路中的 PlayFab 實體識別碼與 MPSD 交互參照。如需透過 MPSD 區分 XBOX Live 玩家與非 XBOX Live 玩家的詳細資訊，請參閱[維護多人遊戲工作階段文件](#maintaining-a-multiplayer-session-document)一節。

如需在與 XBOX Live 的跨平台遊玩網路中識別使用者之相關需求的詳細資訊，請參閱 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007)。

<a id="respecting-cross-network-communication-permissions-for-xbox-live-users" />

### 遵守 XBOX Live 使用者的跨網路通訊權限

PlayFab Party 不會隱含地遵循 XBOX Live 的跨網路通訊限制。因此，PlayFab Party XBOX Live Helper 程式庫提供查詢 XBOX Live 使用者跨網路通訊權限的功能。您必須使用此資訊來遵循 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) 中指定的跨網路通訊需求。

如需詳細資訊，請參閱[遵守跨網路通訊](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide#respecting-cross-network-communication-permissions)。

<a id="use-playfab-party-invitations-to-restrict-access-to-networks-when-cross-play-is-not-allowed" />

### 在不允許跨平台遊玩時，使用 PlayFab Party 邀請限制網路存取。

XBOX Live 使用者需要跨網路權限，才能在跨網路遊戲工作階段中與非 XBOX Live 使用者互動。PlayFab Party 不會隱含地遵循這些跨網路限制 (如 [XR-007](https://developer.microsoft.com/games/xbox/docs/gdk/xr007) 中所述)，因此必須在 PlayFab Party 程式庫之外查詢此權限。未授與這些權限時，您應限制 Party 網路，只允許遊戲工作階段 MPSD 文件中已知的 XBOX Live 使用者。您可以擴充我們的範例[中途加入流程](/zh-TW/services/playfab/multiplayer/networking/using-mpsd#join-in-progress)，使用只允許已知 XBOX 使用者加入網路的 Party 邀請來達成此目的。

首先，請確保以受限制的邀請建立 Party 網路。

```cpp theme={null}
PartyString networkCreatorEntityId;
RETURN_VOID_IF_FAILED(m_localPartyUser->GetEntityId(&networkCreatorEntityId));

PartyInvitationConfiguration newNetworkInitialInvite{};
newNetworkInitialInvite.identifier = nullptr; // let Party select the invitation identifier for simplicity
newNetworkInitialInvite.revocability = PartyInvitationRevocability::Anyone; // the initial invitation must be revocable by anyone

// this initial invitation only allows the original xbl user creating the network
newNetworkInitialInvite.entityIdCount = 1;
newNetworkInitialInvite.entityIds = &networkCreatorEntityId;

PartyError error = PartyManager::GetSingleton().CreateNewNetwork(
    m_localPartyUser,
    &networkConfiguration,
    0,
    nullptr,
    &newNetworkInitialInvite,
    nullptr,
    nullptr,
    nullptr);
```

與[中途加入流程](/zh-TW/services/playfab/multiplayer/networking/using-mpsd#join-in-progress)類似，當新的 XBOX 使用者想要加入網路時，他們會先將自己新增至工作階段文件。當想要允許他們進入網路的玩家看到更新時，該玩家會更新邀請集合以反映工作階段文件。這可確保只有工作階段文件中的使用者 (保證為 XBOX Live 使用者) 可以加入網路。

```cpp theme={null}
void
OnSessionDocumentUpdated(
    PartyNetwork* network,
    uint32_t usersInDocumentCount,
    const uint64_t* usersInDocument
    )
{
    PartyInvitationConfiguration newInvite{};
    newInvite.identifier = nullptr; // let Party select the invitation identifier for simplicity
    newInvite.revocability = PartyInvitationRevocability::Creator; // must be revocable by the creator only

    // the updated invite should contain all users currently in the document
    std::vector<PartyString> entityIdsInDocument;
    for (uint32_t i = 0; i < usersInDocumentCount; ++i)
    {
        uint64_t xboxUserId = usersInDocument[i];
        // Call title-defined xuid->entityid mapping helper
        PartyString xboxUserEntityId = GetEntityIdFromXboxUserId(xboxUserId);
        if (xboxUserEntityId != nullptr)
        {
            entityIdsInDocument.push_back(xboxUserEntityId);
        }
        else
        {
            DEBUGLOG("User %llu did not have a matching entity ID.", xboxUserId);
        }
    }
    newInvite.entityIdCount = entityIdsInDocument.size();
    newInvite.entityIds = entityIdsInDocument.data();

    // Create a new invitation which includes all of the users currently in the document
    PartyInvitation* newInvitation;
    PartyError error = network->CreateInvitation(
        m_localUser,
        &newInvite,
        nullptr,
        &newInvitation);
    if (PARTY_FAILED(error))
    {
        DEBUGLOG("PartyNetwork(0x%p)::CreateInvitation failed! (error=0x%x)", network, error);
        return;
    }

    // Post the invitation's id somewhere that it can be seen by anyone trying to join/rejoin
    PostInvitationToMPSD(newInvite);

    // Cleanup previous invitations. This isn't strictly necessary, but is a good practice.
    uint32_t invitationCount;
    PartyInvitationArray invitations;
    error = network->GetInvitations(&invitationCount, &invitations);
    if (PARTY_FAILED(error))
    {
        DEBUGLOG("PartyNetwork(0x%p)::GetInvitations failed! (error=0x%x)", network, error);
        return;
    }

    for (uint32_t i = 0; i < invitationCount; ++i)
    {
        if (invitations[i] == newInvite)
        {
            continue; // don't prune the old invitation
        }

        PartyInvitation* oldInvitation = invitations[i];

        error = network->RevokeInvitation(m_localUser, oldInvitation, nullptr);
        if (PARTY_FAILED(error))
        {
            DEBUGLOG("PartyNetwork(0x%p)::RevokeInvitation failed! (err=0x%x)", network, error);
        }
    }
}
```

<Note>
  由於您需要在 XBOX Live 使用者識別碼與 PlayFab 實體識別碼之間進行轉譯，建議建立兩者之間的對應。如需相關做法的範例，請參閱 [XBOX Live 使用者識別碼與 PlayFab 實體識別碼之間的對應](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide#mapping-between-xbox-live-user-ids-and-playfab-entity-ids)。
</Note>

<a id="keeping-in-sync-with-xbox-live-profile-settings" />

## 與 XBOX Live 設定檔設定保持同步

根據預設，PlayFab Party 符合 [XR-048](https://developer.microsoft.com/games/xbox/docs/gdk/xr048) 中的設定檔設定需求。程式庫不會保留任何 XBOX Live 設定檔設定的永續性快取。當 PlayFab Party 需要使用設定檔設定時，會從 XBOX Live 查詢這些設定，且這些設定在與該設定相關聯之 PlayFab Party API 物件的存留期間內保持有效，但不會在物件的多個執行個體之間保留。

如需在 PlayFab Party 之外使用 XBOX Live 設定檔設定資料的資訊，請參閱 [XR-048](https://developer.microsoft.com/games/xbox/docs/gdk/xr048) 技術文件。

<a id="supporting-platform-multiplayer-join-flows" />

## 支援平台多人遊戲加入流程

在 XBOX 上，玩家可以透過中途加入和平台邀請功能加入多人遊戲。PlayFab Party 不會直接與這些平台功能整合，但透過 `PartyNetworkDescriptor` 和 `PartyInvitation` 物件支援其使用。`PartyNetworkDescriptor` 物件提供遠端使用者尋找並連線至 Party 網路所需的連線資訊，並可透過 `PartyManager::SerializeNetworkDescriptor` 序列化。`PartyInvitation` 物件為遠端使用者提供識別碼，用來驗證並加入 Party 網路。若要讓遠端使用者透過中途加入和平台邀請加入多人遊戲，請將序列化的網路描述元和 Party 邀請識別碼整合至您現有的流程中。範例流程也可以在[搭配 MPSD 使用 PlayFab Party](/zh-TW/services/playfab/multiplayer/networking/using-mpsd) 文件中找到。

如需平台多人遊戲加入流程需求的詳細資訊，請參閱 [XR-064](https://developer.microsoft.com/games/xbox/docs/gdk/xr064) 和 [XR-124](https://developer.microsoft.com/games/xbox/docs/gdk/console-certification-requirements-and-tests) 技術文件。

<a id="friends-lists" />

## 好友清單

雖然 PlayFab Party 不會原生地與任何平台上的好友清單互動，但多人遊戲仍可能需要在不同案例中考量好友清單。如需與 XBOX Live 和跨網路好友清單互動時的需求和指引資訊，請參閱下列文件：

* [XBOX Live 好友清單需求 (XR-070)](https://developer.microsoft.com/games/xbox/docs/gdk/console-certification-requirements-and-tests)
* [跨網路好友清單需求 (XR-007)](https://developer.microsoft.com/games/xbox/docs/gdk/xr007)
* [XBOX Social Manager](https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/live/get-started/live-xbl-overview)
* [XBOX Live Services API (XSAPI)](https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/live/get-started/live-xbl-overview)

<a id="honoring-xbox-live-service-retry-policy-and-service-access-limitations" />

## 遵守 XBOX Live 服務重試原則和服務存取限制。

PlayFab Party 不會在 [XBOX Live Helper 程式庫](/zh-TW/services/playfab/multiplayer/networking/party-xbox-live-guide)之外直接與 XBOX Live 服務互動。XBOX Live Helper 程式庫在內部遵循 [XR-074](https://developer.microsoft.com/games/xbox/docs/gdk/xr074) 和 [XR-132](https://developer.microsoft.com/games/xbox/docs/gdk/xr132) 中所述之相關 XBOX Live 服務的重試原則和存取限制。此外，您可以透過 XBOX Live Helper 程式庫回報的下列錯誤碼，識別因遵循這些服務原則而導致的 API 失敗：[PartyXblChatPermissionMaskReason::XboxLiveServiceError](/zh-TW/services/playfab/multiplayer/networking/xblreference/enums/partyxblchatpermissionmaskreason) 和 [PartyXblStateChangeResult::PartyServiceError](/zh-TW/services/playfab/multiplayer/networking/xblreference/enums/partyxblstatechangeresult)。

如需在 XBOX Live Helper 程式庫之外遵循這些服務原則的詳細資訊，請參閱 [XR-074](https://developer.microsoft.com/games/xbox/docs/gdk/xr074) 和 [XR-132](https://developer.microsoft.com/games/xbox/docs/gdk/xr132) 技術文件。


## Related topics

- [原則與 XBOX 需求](/zh-TW/publishing/certification/overview.md)
- [XBOX 遊戲的 XBOX 需求](/zh-TW/publishing/certification/xbox-requirements.md)
- [XBOX 遊戲的認證測試 XBOX 需求](/zh-TW/publishing/certification/console-cert-tested-requirements.md)
- [XBOX 需求與原則支援內容](/zh-TW/publishing/certification/xr/overview.md)
- [Beta 版與 XBOX Game Preview 遊戲產品的需求](/zh-TW/publishing/certification/cert-beta-game-preview.md)
