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

# XGameStreamingGetSessionId

> XGameStreamingGetSessionId

# XGameStreamingGetSessionId

이 API는 지정한 클라이언트의 스트리밍 세션을 고유하게 식별하는 null 종료 불투명(opaque) 문자열을 반환합니다.

## 구문

```cpp theme={null}
HRESULT XGameStreamingGetSessionId(
        XGameStreamingClientId client,
        size_t sessionIdSize,
        char* sessionId,
        size_t* sessionIdUsed
)
```

### 매개 변수

*client*   \_In\_\
형식: XGameStreamingClientId

쿼리 대상 스트리밍 클라이언트입니다.

*sessionIdSize*   \_In\_\
형식: size\_t

`sessionId` 버퍼의 크기입니다.

*sessionId*   \_Out\_writes\_bytes\_to\_(sessionIdSize, \*sessionIdUsed)\
형식: char\*

지정한 클라이언트의 세션 ID로 채워질 버퍼입니다.

*sessionIdUsed*   \_Out\_opt\_\
형식: size\_t\*

`sessionId` 버퍼에 반환된 값의 크기(바이트 단위이며, null 종료 문자 포함)입니다.

### 반환 값

형식: HRESULT

성공하면 **S\_OK**를 반환하고, 그렇지 않으면 오류 코드를 반환합니다.

#### 잠재적 오류

| 오류 코드                                    | 오류 값       | 오류 원인                                                                                                                                                    |
| ---------------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400 | XGameStreaming 런타임이 초기화되지 않았습니다. 다른 API를 호출하기 전에 [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize)를 호출하세요. |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 지정한 클라이언트가 연결되어 있지 않습니다.                                                                                                                                 |
| E\_GAMESTREAMING\_NO\_DATA               | 0x89245402 | 요청한 데이터를 사용할 수 없습니다. 데이터는 나중에 사용할 수 있게 될 수 있습니다.                                                                                                         |
| E\_NOT\_SUFFICIENT\_BUFFER               | 0x7A       | *sessionId*가 세션 ID와 null 종료 문자를 담기에 충분하지 않습니다.                                                                                                           |

오류 코드 목록은 [오류 코드](/reference/errorcodes)를 참조하세요.

## 설명

`sessionId`에 기록되는 문자열은 `SessionIdMaxBytes`보다 커지지 않으므로 미리 할당할 수 있습니다. `sessionId`의 레이아웃/내용은 향후 변경될 수 있으므로 불투명한 문자열로만 해석해야 합니다. 다른 클라이언트 속성 API와 마찬가지로, `sessionId`의 변경 사항을 알리는 콜백을 등록하려면 `XGameStreamingRegisterClientPropertiesChanged`를 사용하는 것이 좋습니다.

## 예제

```C++ theme={null}
// Register for client properties changed notifications 
void GameStreamingClientManager::OnClientConnected(XGameStreamingClientId client)
{
    XGameStreamingClientPropertiesChangedRegistrationToken token = {0};
    XGameStreamingRegisterClientPropertiesChanged(
            client, m_taskQueue, this, &OnClientPropertiesChanged, &token);
}

void GameStreamingClientManager::OnClientPropertiesChanged(
    void* context,
    XGameStreamingClientId client,
    uint32_t updatedPropertiesCount,
    XGameStreamingClientProperty* updatedProperties)
{
    for (uint32_t i = 0; i < updatedPropertiesCount; ++i)
    {
        switch (updatedProperties[i])
        {
        case XGameStreamingClientProperty::SessionId:
        {
            // allocate memory for sessionId
            char sessionId[SessionIdMaxBytes];

            // get session id of the client
            size_t bytesUsed = 0;
            HRESULT hr = XGameStreamingGetSessionId(client, _countof(sessionId), sessionId, &bytesUsed);

            if (SUCCEEDED(hr)) {
                // Game logic to use session id
            }
            else if (hr == E_GAMESTREAMING_NO_DATA) {
                // Game logic to handle no data for client
            }
            else
            {
                // Default error case
                LogFormat(L"XGameStreamingGetSessionId failed %x", hr);
            }

            break;
        }

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

```

## 요구 사항

**헤더:** xgamestreaming.h\
**라이브러리:** xgameruntime.lib\
**지원 플랫폼:** Windows, XBOX One 계열 콘솔 및 XBOX Series 콘솔

## 함께 보기

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)
[XGameStreamingRegisterClientPropertiesChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterclientpropertieschanged)


## Related topics

- [XGameStreamingClientProperty](/ko/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [XGameStreaming](/ko/reference/system/xgamestreaming/xgamestreaming_members.md)
- [GDK용 Unity C# API 래퍼](/ko/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XGameStreamingGetClients](/ko/reference/system/xgamestreaming/functions/xgamestreaminggetclients.md)
- [XGameStreamingGetConnectionState](/ko/reference/system/xgamestreaming/functions/xgamestreaminggetconnectionstate.md)
