Skip to content

Wraps the PlayFab admin API to return tasks (Consider using PlayFab C# SDK instead of this solution)

Notifications You must be signed in to change notification settings

Breakstep-Studios/playfab-admin-api-task-wrapper

Repository files navigation

PlayFab Admin API Task Wrapper

The PlayFab admin API Task wrapper wraps the Unity admin API to convert the async callback pattern to task async await pattern.

Usage Note

In most cases it would be preferrable to utilize the PlayFab C# SDK (Additional notes here) within Unity. This tool is most beneficial for projects that have already gone the Unity SDK route and are looking to gradually move code base to async await pattern.

Quick Start

Add the following line to your Unity package Packages/manifest.json

{
  "dependencies": {
    "com.breakstepstudios.playfab-admin-api-task-wrapper": "https://github.com/Breakstep-Studios/playfab-admin-api-task-wrapper.git#release",
  }
}

Examples

Example Conversion

/// <inheritdoc cref="PlayFabAdminAPI.GetTitleData"/>
public static Task<PlayFabCommonResponse<GetTitleDataResult>> GetTitleDataAsync(
    GetTitleDataRequest request)
{
    var taskCompletionSource = new TaskCompletionSource<PlayFabCommonResponse<GetTitleDataResult>>();
    PlayFabAdminAPI.GetTitleData(request, (result) =>
    {
        taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(result,null));
    }, (error) =>
    {
        taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(null, error));
    });
    return taskCompletionSource.Task;
}

Example Usage

public async PlayFabCommonResponse<GetTitleDataResult> GetTitleDataData()
{
    var getTitleDataRequest = new GetTitleDataRequest
    {
        Keys = new List<string> { "Data" }
    };
    var result = await PlayFabAdminAPIWrapper.GetTitleDataAsync(getTitleDataRequest);
    if (result.ContainsError)
    {
        return result;
    }
}

TODO

  • This package currently relies on playfab-admin-client-task-wrapper. This dependency is only due to the fact that playfab-client-api-task-wrapper defines some data models this repo relies/will rely on. In the long run it would more beneficial to pull those data models in to a seperate repo that both the client & admin api rely on. For example something like playfab-core-api-task-wrapper.

About

Wraps the PlayFab admin API to return tasks (Consider using PlayFab C# SDK instead of this solution)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages