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

# 소셜 관계 변경 처리하기

> XBOX Live 소셜 관계 변경 이벤트를 구독하고 사용자의 친구 목록이 업데이트될 때 핸들러를 추가하거나 제거하기 위한 XSAPI 코드입니다.

이 항목에서는 소셜 관계 변경을 처리하기 위한 예제 코드를 제공합니다.

## 관계 변경 구독하기

**Flat C API**

```cpp theme={null}
HRESULT hr = XblSocialSubscribeToSocialRelationshipChange(
    xboxLiveContext, 
    xboxUserId,
    &state.socialSubscriptionHandle
);
```

## 관계 변경 구독 취소하기

**Flat C API**

```cpp theme={null}
HRESULT hr = XblSocialUnsubscribeFromSocialRelationshipChange(
    xboxLiveContext, 
    state.socialSubscriptionHandle
);

state.socialSubscriptionHandle = nullptr;
```

## 관계 변경 핸들러 추가하기

**Flat C API**

```cpp theme={null}
state.socialRelationshipChangedHandlerToken = XblSocialAddSocialRelationshipChangedHandler(
    xboxLiveContext,
    [](const XblSocialRelationshipChangeEventArgs* args, void* context)
    {
        UNREFERENCED_PARAMETER(context);
        LogToFile("Social relationship changed:");
        std::stringstream ss;
        for (size_t i = 0; i < args->xboxUserIdsCount; ++i)
        {
            if (i > 0) 
            {
                ss << ", ";
            }
            ss << args->xboxUserIds[i];
        }
        LogToFile("socialNotification = %u, affectedXuids = %s", args->socialNotification, ss.str().data());
    },
    nullptr
);
```

## 관계 변경 핸들러 제거하기

**Flat C API**

```cpp theme={null}
HRESULT hr = XblSocialRemoveSocialRelationshipChangedHandler(xboxLiveContext, state.socialRelationshipChangedHandlerToken);
state.socialRelationshipChangedHandlerToken = 0;
```

## 참고 항목

[XblSocialAddSocialRelationshipChangedHandler](/reference/live/xsapi-c/social_c/functions/xblsocialaddsocialrelationshipchangedhandler)
[XblSocialRemoveSocialRelationshipChangedHandler](/reference/live/xsapi-c/social_c/functions/xblsocialremovesocialrelationshipchangedhandler)


## Related topics

- [People 시스템(친구 목록) 예제 코드](/ko/services/xbox-services/community/people-system/how-to/live-pplsys-howto-nav.md)
- [방법](/ko/services/xbox-services/community/people-system/how-to/index.md)
- [장치 Presence 변경 처리](/ko/services/xbox-services/community/presence/how-to/live-handling-a-device-presence-change.md)
- [타이틀 Presence 변경 처리](/ko/services/xbox-services/community/presence/how-to/live-handling-a-title-presence-change.md)
- [XblSocialRemoveSocialRelationshipChangedHandler](/ko/reference/live/xsapi-c/social_c/functions/xblsocialremovesocialrelationshipchangedhandler.md)
