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

# 云感知 API 调用

> 云感知 API 调用

使用本主题来检测您的云感知游戏是否具备串流能力，以便您能[针对 XBOX 游戏串流优化您的游戏](/build/core-features/common/game-streaming/game-streaming-optimizing-your-game)。

## 为串流设置您的游戏

在游戏初始化期间，请确保通过 `XGameStreamingInitialize` 设置游戏串流组件，如下代码所示。

```C++ theme={null}

// Initialize the game streaming component
XGameStreamingInitialize();

```

要检测当前是否有任何已连接的活动串流客户端，请使用 `XGameStreamingIsStreaming`，如下代码所示。

```C++ theme={null}
 if (XGameStreamingIsStreaming())
 {
     // The game is currently streaming to at least one device
     // Enable any customizations that might be useful when running from the cloud
 }
```

## 管理连接状态

如果存在活动的串流客户端，您的游戏在使用 `XGameStreamingIsStreaming` 时能够获得这些客户端的即时快照信息。要在串流客户端连接到您的游戏或从中断开时接收通知，请使用 [XGameStreamingRegisterConnectionStateChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)。

## 参考 API 文档

* [XGameStreaming（API 内容）](/reference/system/xgamestreaming/xgamestreaming_members)
  * 函数
    * [XGameStreamingRegisterConnectionStateChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)

## 另请参阅

[XGameStreaming（API 内容）](/reference/system/xgamestreaming/xgamestreaming_members#connection-state)
[优化您的游戏](/build/core-features/common/game-streaming/game-streaming-optimizing-your-game)


## Related topics

- [XGameStreamingRegisterConnectionStateChanged](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged.md)
- [针对 XBOX 游戏串流优化您的游戏](/zh-CN/build/core-features/common/game-streaming/game-streaming-optimizing-your-game.md)
- [XBOX Cloud Gaming 触控与流式传输支持](/zh-CN/build/core-features/common/game-streaming/index.md)
- [为串流设置 XBOX 开发套件](/zh-CN/build/core-features/common/game-streaming/game-streaming-setup-xbox-developer-kit.md)
- [游戏串流简介](/zh-CN/build/core-features/common/game-streaming/game-streaming-overview.md)
