> ## 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 Game Streaming [最佳化您的遊戲](/zh-TW/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](/zh-TW/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)。

## 參考 API 文件

* [XGameStreaming (API 內容)](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members)
  * 函式
    * [XGameStreamingRegisterConnectionStateChanged](/zh-TW/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)

## 另請參閱

[XGameStreaming (API 內容)](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members#connection-state)
[最佳化您的遊戲](/zh-TW/build/core-features/common/game-streaming/game-streaming-optimizing-your-game)


## Related topics

- [Godot 與社群引擎總覽](/zh-TW/paths/community-engines/overview.md)
- [XBOX 遊戲開發文件](/zh-TW/index.md)
- [云感知 API 调用](/zh-CN/build/core-features/common/game-streaming/game-streaming-am-i-streaming.md)
- [XR-132 服務存取限制](/zh-TW/publishing/certification/xr/xr-132.md)
- [XAG 103：视觉与音频提示的补充通道](/zh-CN/build/game-principles/accessibility/xag-deep-dives/xag-103-additional-cues.md)
