NAV
Unity Unreal Engine 4

GS2-Distributor

GS2-SDK for Game Engine のリファレンス

ゲームエンジン向けSDKモデル

EzDistributorModel

配信設定とはエンティティの入手時に所持枠を超えて入手した時のポリシーを設定するエンティティです。 GS2-Distributor を通して入手処理を行うことで、あふれたリソースを GS2-Inbox のメッセージとして転送することができます。

説明
name string 配信設定名
metadata string メタデータ
inboxNamespaceId string ネームスペースGRN
whiteListTargetIds string[] ディストリビューターを通して処理出来る対象のリソースGRNのホワイトリスト

EzDistributeResource

説明
action string スタンプシートで実行するアクションの種類
request string 消費リクエストのJSON

メソッド

getDistributorModel

getDistributorModel

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.getDistributorModel(
    [](gs2::ez::account::AsyncEzGetDistributorModelResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.getDistributorModel failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
        }
    },
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("distributor-model-0001") // distributorName
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzGetDistributorModelResult> asyncResult = null;
    var current = gs2.Distributor.GetDistributorModel(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1",
        distributorName: "distributor-model-0001"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
}

配信設定を認証

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
distributorName string ~ 128文字 配信設定名

Result

説明
item DistributorModel 配信設定

listDistributorModels

listDistributorModels

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.describeDistributorModels(
    [](gs2::ez::account::AsyncEzDescribeDistributorModelsResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.describeDistributorModels failed.");
        }
        else
        {
            Items = r.getResult()->getItems();
        }
    },
    TCHAR_TO_ANSI("namespace1") // namespaceName
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzDescribeDistributorModelsResult> asyncResult = null;
    var current = gs2.Distributor.DescribeDistributorModels(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var items = result.Items;
}

配信設定を認証

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名

Result

説明
items DistributorModel[] 配信設定のリスト

runStampSheet

runStampSheet

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampSheet(
    [](gs2::ez::account::AsyncEzRunStampSheetResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampSheet failed.");
        }
        else
        {
            Result = r.getResult()->getResult();
        }
    },
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("$stampSheet"), // stampSheet
    TCHAR_TO_ANSI("$key1.keyId") // keyId,
    TCHAR_TO_ANSI(null) // contextStack
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampSheetResult> asyncResult = null;
    var current = gs2.Distributor.RunStampSheet(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1",
        stampSheet: "$stampSheet",
        keyId: "$key1.keyId",
        contextStack: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var result = result.Result;
}

スタンプシートを実行

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
stampSheet string ~ 5242880文字 スタンプシート
keyId string ~ 1024文字 暗号鍵GRN
contextStack string ~ 32768文字

Result

説明
result string レスポンス内容

runStampSheetExpress

runStampSheetExpress

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampSheetExpress(
    [](gs2::ez::account::AsyncEzRunStampSheetExpressResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampSheetExpress failed.");
        }
        else
        {
            TaskResults = r.getResult()->getTaskResults();
            SheetResult = r.getResult()->getSheetResult();
        }
    },
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("$stampSheet"), // stampSheet
    TCHAR_TO_ANSI("$key1.keyId") // keyId
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampSheetExpressResult> asyncResult = null;
    var current = gs2.Distributor.RunStampSheetExpress(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1",
        stampSheet: "$stampSheet",
        keyId: "$key1.keyId"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var taskResults = result.TaskResults;
    var sheetResult = result.SheetResult;
}

スタンプタスク・スタンプシートを一括実行

一括実行をすることで、レスポンスタイムを短縮できます。 ただし、スタンプシートの実行の過程で失敗した際には正しくリトライできる保証はありません。 実行に失敗した時に備えて GS2-Log でスタンプシートの実行ログを残しておき、カスタマーサポートの際に適切な対応ができるようにしておくことを強く推奨します。

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
stampSheet string ~ 5242880文字 スタンプシート
keyId string ~ 1024文字 暗号鍵GRN

Result

説明
taskResults string[] スタンプタスクの実行結果
sheetResult string スタンプシートの実行結果レスポンス内容

runStampSheetExpressWithoutNamespace

runStampSheetExpressWithoutNamespace

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampSheetExpressWithoutNamespace(
    [](gs2::ez::account::AsyncEzRunStampSheetExpressWithoutNamespaceResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampSheetExpressWithoutNamespace failed.");
        }
        else
        {
            TaskResults = r.getResult()->getTaskResults();
            SheetResult = r.getResult()->getSheetResult();
        }
    },
    TCHAR_TO_ANSI("$stampSheet"), // stampSheet
    TCHAR_TO_ANSI("$key1.keyId") // keyId
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampSheetExpressWithoutNamespaceResult> asyncResult = null;
    var current = gs2.Distributor.RunStampSheetExpressWithoutNamespace(
        callback: r => { asyncResult = r; },
        stampSheet: "$stampSheet",
        keyId: "$key1.keyId"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var taskResults = result.TaskResults;
    var sheetResult = result.SheetResult;
}

スタンプタスク・スタンプシートを一括実行

一括実行をすることで、レスポンスタイムを短縮できます。 ただし、スタンプシートの実行の過程で失敗した際には正しくリトライできる保証はありません。 実行に失敗した時に備えて GS2-Log でスタンプシートの実行ログを残しておき、カスタマーサポートの際に適切な対応ができるようにしておくことを強く推奨します。

ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。

Request

必須 デフォルト 値の制限 説明
stampSheet string ~ 5242880文字 スタンプシート
keyId string ~ 1024文字 暗号鍵GRN

Result

説明
taskResults string[] スタンプタスクの実行結果
sheetResult string スタンプシートの実行結果レスポンス内容

runStampSheetWithoutNamespace

runStampSheetWithoutNamespace

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampSheetWithoutNamespace(
    [](gs2::ez::account::AsyncEzRunStampSheetWithoutNamespaceResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampSheetWithoutNamespace failed.");
        }
        else
        {
            Result = r.getResult()->getResult();
        }
    },
    TCHAR_TO_ANSI("$stampSheet"), // stampSheet
    TCHAR_TO_ANSI("$key1.keyId") // keyId,
    TCHAR_TO_ANSI(null) // contextStack
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampSheetWithoutNamespaceResult> asyncResult = null;
    var current = gs2.Distributor.RunStampSheetWithoutNamespace(
        callback: r => { asyncResult = r; },
        stampSheet: "$stampSheet",
        keyId: "$key1.keyId",
        contextStack: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var result = result.Result;
}

スタンプシートを実行

ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。

Request

必須 デフォルト 値の制限 説明
stampSheet string ~ 5242880文字 スタンプシート
keyId string ~ 1024文字 暗号鍵GRN
contextStack string ~ 32768文字

Result

説明
result string レスポンス内容

runStampTask

runStampTask

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampTask(
    [](gs2::ez::account::AsyncEzRunStampTaskResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampTask failed.");
        }
        else
        {
            ContextStack = r.getResult()->getContextStack();
            Result = r.getResult()->getResult();
        }
    },
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("$stampTask"), // stampTask
    TCHAR_TO_ANSI("$key1.keyId") // keyId,
    TCHAR_TO_ANSI(null) // contextStack
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampTaskResult> asyncResult = null;
    var current = gs2.Distributor.RunStampTask(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1",
        stampTask: "$stampTask",
        keyId: "$key1.keyId",
        contextStack: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var contextStack = result.ContextStack;
    var result = result.Result;
}

スタンプタスクを実行

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
stampTask string ~ 5242880文字 スタンプタスク
keyId string ~ 1024文字 暗号鍵GRN
contextStack string ~ 32768文字

Result

説明
contextStack string タスクの実行結果を反映したコンテキストスタック
result string レスポンス内容

runStampTaskWithoutNamespace

runStampTaskWithoutNamespace

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->distributor.runStampTaskWithoutNamespace(
    [](gs2::ez::account::AsyncEzRunStampTaskWithoutNamespaceResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "distributor.runStampTaskWithoutNamespace failed.");
        }
        else
        {
            ContextStack = r.getResult()->getContextStack();
            Result = r.getResult()->getResult();
        }
    },
    TCHAR_TO_ANSI("$stampTask"), // stampTask
    TCHAR_TO_ANSI("$key1.keyId") // keyId,
    TCHAR_TO_ANSI(null) // contextStack
);
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzRunStampTaskWithoutNamespaceResult> asyncResult = null;
    var current = gs2.Distributor.RunStampTaskWithoutNamespace(
        callback: r => { asyncResult = r; },
        stampTask: "$stampTask",
        keyId: "$key1.keyId",
        contextStack: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var contextStack = result.ContextStack;
    var result = result.Result;
}

スタンプタスクを実行

ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。

Request

必須 デフォルト 値の制限 説明
stampTask string ~ 5242880文字 スタンプタスク
keyId string ~ 1024文字 暗号鍵GRN
contextStack string ~ 32768文字

Result

説明
contextStack string タスクの実行結果を反映したコンテキストスタック
result string レスポンス内容