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

# 订阅实时消息资源

> PlayFab Lobby 和 Matchmaking 客户端通过实时消息 SignalR 中心订阅资源主题,使用 StartOrRecoverSession 返回的连接句柄。

> [!NOTE]
>
> 此处记录的 REST 和 SignalR API 比客户端 SDK 更复杂。除非这些 SDK 不能满足你的需求,否则请考虑使用 [Lobby C++ SDK](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members.md) 或 [Matchmaking C++ SDK](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmatchmaking/pfmatchmaking_members.md)。

在客户端[连接到 SignalR 中心](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/signalr-hub.md#connecting-to-the-signalr-hub)并调用 [StartOrRecoverSession](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/server-methods/start-or-recover-session.md) 以接收 `Connection Handle` 后,就可以订阅主题并接收消息。订阅 Lobby 或 Matchmaking 资源时,客户端需要提供它们在启动会话时收到的 `Connection Handle`。有关启动和管理会话的详细信息,请参阅 [SignalR 中心](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/signalr-hub.md)概述。

要管理发布消息的服务的资源订阅,请参阅:

| 服务 | 订阅 API | 取消订阅 API |
| - | - | - |
| Lobby 服务 | [SubscribeToLobbyResource](https://learn.microsoft.com/en-us/rest/api/playfab/multiplayer/lobby/subscribe-to-lobby-resource) | [UnsubscribeFromLobbyResource](https://learn.microsoft.com/en-us/rest/api/playfab/multiplayer/lobby/unsubscribe-from-lobby-resource) |
| Matchmaking 服务 | [SubscribeToMatchmakingResource](https://learn.microsoft.com/en-us/rest/api/playfab/multiplayer/matchmaking/subscribe-to-matchmaking-resource) | [UnsubscribeFromMatchmakingResource](https://learn.microsoft.com/en-us/rest/api/playfab/multiplayer/matchmaking/unsubscribe-from-matchmaking-resource) |

## 另请参阅

* [实时消息 SignalR 中心](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/signalr-hub.md)
* [Lobby 和 Matchmaking API 的实时消息](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/overview.md)


## Related topics

- [实时消息 SignalR 中心](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/signalr-hub.md)
- [大厅与匹配实时消息](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/lobby/lobby-and-matchmaking-real-time-messages.md)
- [Lobby 和 Matchmaking API 的实时消息](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/overview.md)
- [SubscriptionChangeMessage 实时消息类型](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/types/subscription-change-message.md)
- [StartOrRecoverSessionResponse 实时消息类型](https://docs.xbox.com/zh-CN/services/playfab/multiplayer/real-time-messages/types/start-or-recover-session-response.md)
