다음을 통해 공유


XSAPI C를 통한 사용자의 프레즌스 업데이트

이 항목에서는 사용자의 온라인 현재 상태 설정을 위한 예제 코드를 제공합니다. Xbox 서비스 리치 프레즌스는 플레이어의 현재 활동을 다른 플레이어에게 알리는 기능을 제공합니다.

자세한 내용은 리치 프레즌스 개요를 참조하세요.

사용자의 온라인 프레즌스 상태 업데이트

이 예제 코드는 사용자의 온라인 프레즌스 상태를 설정합니다.

플랫 C API

auto asyncBlock = std::make_unique<XAsyncBlock>();
asyncBlock->queue = queue;
asyncBlock->context = nullptr;
asyncBlock->callback = [](XAsyncBlock* asyncBlock)
{
    std::unique_ptr<XAsyncBlock> asyncBlockPtr{ asyncBlock }; // Take over ownership of XAsyncBlock*.
    HRESULT hr = XAsyncGetStatus(asyncBlock, false);
};

HRESULT hr = XblPresenceSetPresenceAsync(xboxLiveContext, true, nullptr, asyncBlock.get());
if (SUCCEEDED(hr))
{
    // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* because the callback will take over ownership.
    // If the call fails, std::unique_ptr will keep ownership and delete XAsyncBlock*.
    asyncBlock.release();
}

자세한 내용은 다음을 참조하세요.

리치 프레즌스 문자열 업데이트

플랫 C API

XblPresenceRichPresenceIds ids{};
pal::strcpy(ids.scid, sizeof(ids.scid), scid);
ids.presenceId = "playingMap";
std::vector<const char*> tokenIds{ "CurrentMap" };
ids.presenceTokenIds = tokenIds.data();
ids.presenceTokenIdsCount = tokenIds.size();

HRESULT hr = XblPresenceSetPresenceAsync(xboxLiveContext, true, &ids, asyncBlock.get());

자세한 내용은 다음을 참조하세요.