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

# XGameStreamingRegisterClientPropertiesChanged

> XGameStreamingRegisterClientPropertiesChanged

# XGameStreamingRegisterClientPropertiesChanged

注册一个回调，当任何流式处理客户端设备的属性发生更改时调用该回调。

<Note>注册后，将使用客户端设备当前的客户端属性调用回调。</Note>

## 语法

```cpp theme={null}
HRESULT XGameStreamingRegisterClientPropertiesChanged(  
         XGameStreamingClientId client,  
         XTaskQueueHandle queue,  
         void* context,  
         XGameStreamingClientPropertiesChangedCallback* callback,  
         XTaskQueueRegistrationToken* token  
)  
```

### 参数

*client*   \_In\_\
类型：XGameStreamingClientId

你正在为其注册以获取回调的游戏流式处理客户端的 ID。

*queue*   \_In\_opt\_\
类型：XTaskQueueHandle

用于放置更改回调的异步队列的句柄。

*context*   \_In\_opt\_\
类型：void\*

指向将传递给回调函数的上下文的可选指针。

*callback*   \_In\_\
类型：[XGameStreamingClientPropertiesChangedCallback\*](/reference/system/xgamestreaming/functions/xgamestreamingclientpropertieschangedcallback)

当客户端属性发生更改时将调用的回调函数。

*token*   \_Out\_\
类型：XTaskQueueRegistrationToken\*

指向可用于从事件中取消注册的注册令牌的指针。

### 返回值

类型：HRESULT

如果成功，则返回 **S\_OK**；否则返回错误代码。

#### 潜在错误

| 错误代码                                     | 错误值        | 错误原因                                                                                                                                       |
| ---------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400 | XGameStreaming 运行时尚未初始化。在调用其他 API 之前，请先调用 [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize)。 |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定的客户端未连接。                                                                                                                                 |

有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。

## 备注

<Note>在时间敏感线程上调用此函数并不安全。有关详细信息，请参阅[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

此 API 允许游戏在 [XGameStreamingClientProperty](/reference/system/xgamestreaming/enums/xgamestreamingclientproperty)（如流物理尺寸）发生更改时接收 `XGameStreamingClientPropertiesChangedCallback`。

注册**将**导致回调被所有适用的 `XGameStreamingClientProperty` 调用，以便可以查询当前属性详细信息。

当流式处理客户端设备断开连接时，请使用 [XGameStreamingUnregisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingunregisterclientpropertieschanged) 注销回调。

## 示例

```cpp theme={null}
    // On client connection maintain a list of clients and do per client initialization
    void GameStreamingClientManager::OnClientConnected(XGameStreamingClientId client)
    {
        StreamingClient connectedClient;
        connectedClient.clientId = client;
        connectedClient.propertiesChangedToken = token;

        // Do per-client initialization
        XGameStreamingClientPropertiesChangedRegistrationToken token = {0};
        XGameStreamingRegisterClientPropertiesChanged(
            client, m_taskQueue, this, &OnClientPropertiesChanged, &token);        

        connectedClient.propertiesChangedToken = token;
        m_streamingClients.push_back(connectedClient);
    }

    // Some of the properties of our streaming client have changed, react to any of the changes which apply to our game
    void GameStreamingClientManager::OnClientPropertiesChanged(
        void* context,
        XGameStreamingClientId client,
        uint32_t updatedPropertiesCount,
        XGameStreamingClientProperty* updatedProperties)
    {
        GameStreamingClientManager* gsClientManager = reinterpret_cast<GameStreamingClientManager*>(context);

        for (uint32_t i = 0; i < updatedPropertiesCount; ++i)
        {
            switch (updatedProperties[i])
            {
                // The client now has a new physical size of the game stream - update our list of stream
                // sizes to reflect this.
            case XGameStreamingClientProperty::StreamPhysicalDimensions:
                gsClientManager->UpdateClientPhysicalDimensions(client); 
                break;

            case XGameStreamingClientProperty::TouchInputEnabled: 
                gsClientManager->UpdateClientTouchEnabled(client); 
                break;

            default:
                // A characteristic we are not tracking - do nothing
                break;
            }
        }
    }

```

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 概念性文档

* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XGameStreamingClientProperty](/reference/system/xgamestreaming/enums/xgamestreamingclientproperty)\
[XGameStreamingClientPropertiesChangedCallback](/reference/system/xgamestreaming/functions/xgamestreamingclientpropertieschangedcallback)\
[XGameStreamingUnregisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingunregisterclientpropertieschanged)\
[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)


## Related topics

- [XGameStreamingClientPropertiesChangedCallback](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingclientpropertieschangedcallback.md)
- [XGameStreamingUnregisterClientPropertiesChanged](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingunregisterclientpropertieschanged.md)
- [XGameStreamingClientProperty](/zh-CN/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [XGameStreamingIsTouchInputEnabled](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingistouchinputenabled.md)
- [XGameStreamingGetSessionId](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetsessionid.md)
