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

# XblSocialRelationshipChangedHandler

> 在添加、更改或移除社交关系时调用的回调。它不会接收传入好友请求数量的更改。

# XblSocialRelationshipChangedHandler

在社交关系发生更改时调用的回调。

## 语法

```cpp theme={null}
typedef void (STDAPIVCALLTYPE* XblSocialRelationshipChangedHandler)(  
         _In_ const XblSocialRelationshipChangeEventArgs* eventArgs,  
         _In_opt_ void* context  
);  
```

### 参数

*eventArgs*   \_In\_\
类型：[const XblSocialRelationshipChangeEventArgs\*](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/structs/xblsocialrelationshipchangeeventargs.md)

与关系更改关联的参数。该结构的字段（包括 `xboxUserIds` 数组）仅在回调期间有效。

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

添加处理程序时提供的上下文。

### 返回值

类型：void

## 备注

通过调用 [XblSocialAddSocialRelationshipChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialaddsocialrelationshipchangedhandler.md) 注册此回调。*context* 参数接收你在注册处理程序时传递的 *handlerContext* 值。

*eventArgs* 的 `socialNotification` 成员为 `XblSocialNotificationType::Added`、`XblSocialNotificationType::Changed` 或 `XblSocialNotificationType::Removed`。请复制回调返回后仍需使用的任何 XBOX 用户 ID。

此回调不会接收传入好友请求数量的更改。若要接收这些更改，请通过调用 [XblSocialAddFriendRequestCountChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialaddfriendrequestcountchangedhandler.md) 注册 [XblSocialIncomingFriendRequestCountChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialincomingfriendrequestcountchangedhandler.md)。

你无需单独订阅社交关系更改。添加处理程序时，XBOX Services API (XSAPI) 会为上下文的用户创建 Real-Time Activity (RTA) 订阅，或重用现有订阅。

## 参数属于

[XblSocialAddSocialRelationshipChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialaddsocialrelationshipchangedhandler.md)

## 要求

**头文件：** social\_c.h

**库：** Microsoft.Xbox.Services.142.C.lib 或 Microsoft.Xbox.Services.143.C.lib

## 另请参阅

[social\_c](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/social_c_members.md)\
[XblSocialRelationshipChangeEventArgs](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/structs/xblsocialrelationshipchangeeventargs.md)\
[XblSocialRemoveSocialRelationshipChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialremovesocialrelationshipchangedhandler.md)


## Related topics

- [XblSocialAddSocialRelationshipChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialaddsocialrelationshipchangedhandler.md)
- [social_c](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/social_c_members.md)
- [XblSocialRemoveSocialRelationshipChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialremovesocialrelationshipchangedhandler.md)
- [XblSocialAddFriendRequestCountChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialaddfriendrequestcountchangedhandler.md)
- [XblSocialIncomingFriendRequestCountChangedHandler](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialincomingfriendrequestcountchangedhandler.md)
