다음을 통해 공유


타이틀 엔터티를 사용하여 PlayFab에 액세스

플레이어로 로그인하고 PlayFab 호출을 수행할 수 있는 방법과 마찬가지로 타이틀 엔터티로 인증하고 이를 통해 PlayFab 호출을 수행할 수도 있습니다. 타이틀 엔터티는 플레이어 엔터티에서 사용할 수 없는 특정 함수를 사용할 수 있습니다. 이러한 함수의 대부분은 "server"라는 단어가 접두사로 붙으며, 그러한 예 중 하나는 ServerAddPlayerTag입니다.

타이틀 엔터티 핸들을 가져오면 플레이어로 로그인하는 것과 동일한 초기화 단계가 있습니다. 자세한 내용은 Win32 빠른 시작 문서의 "초기화" 섹션을 참조하세요.

참고: 현재 서버 함수는 SDK의 Win32 버전에서만 사용할 수 있습니다.

타이틀 엔터티 인증

초기 단계에서 PFServiceConfigHandle을 만든 후 PFAuthenticationGetEntityWithSecretKeyAsync를 호출하여 타이틀 엔터티 핸들을 가져올 수있습니다. 엔티티 가져오기 호출이 성공적으로 완료되면, PFEntityHandle과 함께 S_OK를 반환합니다. 이 프로세스는 플레이어로 로그인하는 것과 비슷합니다. PFEntityHandle의 반환 형식은 동일하지만, 이 경우 엔터티 핸들은 플레이어 엔터티가 아닌 제목 엔터티를 나타냅니다. 이 엔터티를 게임 서버라고 할 수 있습니다.

    PFAuthenticationGetEntityRequest request{};
    XAsyncBlock async{};

    // Add your own error handling when FAILED(hr) == true
    HRESULT hr = PFAuthenticationGetEntityWithSecretKeyAsync(
        serviceConfigHandle,
        secretKey, // title specific secret key
        &request,
        &async
    );

    hr = XAsyncGetStatus(&async, true); // This is doing a blocking wait for completion, but you can use the XAsyncBlock to set a callback instead for async style usage

    PFEntityHandle entityHandle;
    hr = PFAuthenticationGetEntityWithSecretKeyGetResult(
        &async,
        &entityHandle
    );

서비스 호출

게임 서버가 만들어지면 PlayFab 백 엔드를 호출할 수 있습니다. 타이틀의 특정 플레이어에 플레이어 태그를 추가하는 예제는 다음과 같습니다.

    XAsyncBlock async{};
    PFSegmentsAddPlayerTagRequest request{};
    addSegmentRequest.PlayFabId = "ABCDEF123456";
    addSegmentRequest.tagName = "tagName";
    HRESULT hr = PFSegmentsServerAddPlayerTagAsync(entityHandle, &request, &async);
    hr = XAsyncGetStatus(&async, true);

AddPlayerTag 예제와 마찬가지로 게임 서버에서 사용하는 많은 함수에는 플레이어 데이터를 가져오거나 변경하는 작업이 포함됩니다. 이 기능을 사용하려면 특정 플레이어의 PlayFab ID가 필요합니다. 연결된 클라이언트는 PlayFab ID를 제공하거나 서버가 GetPlayFabIDsFromXboxLiveIDs와 같은 호출을 통해 PlayFab에서 직접 검색할 수 있습니다.

참조

API 참조 설명서.