GS2-Distributor SDK for Game Engine API リファレンス
モデル
EzDistributorModel
配信設定モデル
配信設定とはエンティティの入手時に所持枠を超えて入手した時のポリシーを設定するエンティティです。 GS2-Distributor を通して入手処理を行うことで、あふれたリソースを GS2-Inbox のメッセージとして転送することができます。
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128文字 | 配信設定名 | |
metadata | string | ~ 2048文字 | メタデータ | ||
inboxNamespaceId | string | ~ 1024文字 | ネームスペースGRN | ||
whiteListTargetIds | List<string> | [] | ディストリビューターを通して処理出来る対象のリソースGRNのホワイトリスト |
EzDistributeResource
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
action | enum [] | ✓ | ~ 128文字 | スタンプシートを使用して実行するアクションの種類 | |
request | string | ✓ | ~ 1048576文字 | リクエストのJSON |
EzStampSheetResult
スタンプシート実行結果
サーバーサイドでのスタンプシート自動実行機能を利用して実行されたスタンプシートの実行結果
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
transactionId | string | ✓ | 36 ~ 36文字 | スタンプシートトランザクションID | |
taskRequests | List<EzConsumeAction> | スタンプタスクのリクエスト内容 | |||
sheetRequest | EzAcquireAction | ✓ | スタンプシートのリクエスト内容 | ||
taskResults | List<string> | スタンプタスクの実行結果 | |||
sheetResult | string | ~ 1048576文字 | スタンプシートの実行結果レスポンス内容 |
EzAcquireAction
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
action | enum [] | ✓ | ~ 128文字 | スタンプシートを使用して実行するアクションの種類 | |
request | string | ✓ | ~ 1048576文字 | リクエストのJSON |
EzConsumeAction
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
action | enum [] | ✓ | ~ 128文字 | スタンプタスクで実行するアクションの種類 | |
request | string | ✓ | ~ 1048576文字 | 入手リクエストのJSON |
メソッド
getDistributorModel
配信設定を取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
distributorName | string | ✓ | ~ 128文字 | 配信設定名 |
Result
型 | 説明 | |
---|---|---|
item | EzDistributorModel | 配信設定 |
実装例
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).DistributorModel(
distributorName: "distributor-model-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).DistributorModel(
distributorName: "distributor-model-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
)->DistributorModel(
"distributor-model-0001" // distributorName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
値の変更イベントハンドリング
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).DistributorModel(
distributorName: "distributor-model-0001"
);
// イベントハンドリングを開始
var callbackId = domain.Subscribe(
value => {
// 値が変化した時に呼び出される
// value には変更後の値が渡ってくる
}
);
// イベントハンドリングを停止
domain.Unsubscribe(callbackId);
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).DistributorModel(
distributorName: "distributor-model-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
)->DistributorModel(
"distributor-model-0001" // distributorName
);
// イベントハンドリングを開始
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Distributor::Model::FDistributorModel> value) {
// 値が変化した時に呼び出される
// value には変更後の値が渡ってくる
}
);
// イベントハンドリングを停止
Domain->Unsubscribe(CallbackId);
Warning
このイベントはSDKがもつローカルキャッシュの値が変更された時に呼び出されます。
ローカルキャッシュは SDK が持つ API の実行、または GS2-Gateway の通知を有効にした GS2-Distributor 経由でのスタンプシートの実行、または GS2-Gateway の通知を有効にした GS2-JobQueue の実行によって変化したもののみが対象となります。
そのため、これらの方法以外で値が変更されてもコールバックは呼び出されません。
listDistributorModels
配信設定の一覧を取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 |
Result
型 | 説明 | |
---|---|---|
items | List<EzDistributorModel> | 配信設定のリスト |
実装例
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
);
var items = await domain.DistributorModelsAsync(
).ToListAsync();
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.DistributorModels(
);
List<EzDistributorModel> items = new List<EzDistributorModel>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
);
const auto It = Domain->DistributorModels(
);
for (auto Item : *It)
{
}
値の変更イベントハンドリング
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
);
// イベントハンドリングを開始
var callbackId = domain.SubscribeDistributorModels(
() => {
// リストの要素が変化した時に呼び出される
}
);
// イベントハンドリングを停止
domain.UnsubscribeDistributorModels(callbackId);
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.DistributorModels(
);
List<EzDistributorModel> items = new List<EzDistributorModel>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
);
// イベントハンドリングを開始
const auto CallbackId = Domain->SubscribeDistributorModels(
[]() {
// リストの要素が変化した時に呼び出される
}
);
// イベントハンドリングを停止
Domain->UnsubscribeDistributorModels(CallbackId);
Warning
このイベントはSDKがもつローカルキャッシュの値が変更された時に呼び出されます。
ローカルキャッシュは SDK が持つ API の実行、または GS2-Gateway の通知を有効にした GS2-Distributor 経由でのスタンプシートの実行、または GS2-Gateway の通知を有効にした GS2-JobQueue の実行によって変化したもののみが対象となります。
そのため、これらの方法以外で値が変更されてもコールバックは呼び出されません。
runStampSheet
スタンプシートを実行
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
stampSheet | string | ✓ | ~ 5242880文字 | スタンプシート | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN | |
contextStack | string | ~ 32768文字 | リクエストコンテキスト |
Result
型 | 説明 | |
---|---|---|
result | string | レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
runStampSheetExpress
スタンプタスク・スタンプシートを一括実行
一括実行をすることで、レスポンスタイムを短縮できます。 ただし、スタンプシートの実行の過程で失敗した際には正しくリトライできる保証はありません。 実行に失敗した時に備えて GS2-Log でスタンプシートの実行ログを残しておき、カスタマーサポートの際に適切な対応ができるようにしておくことを強く推奨します。
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
stampSheet | string | ✓ | ~ 5242880文字 | スタンプシート | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN |
Result
型 | 説明 | |
---|---|---|
taskResults | List<string> | スタンプタスクの実行結果 |
sheetResult | string | スタンプシートの実行結果レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
runStampSheetExpressWithoutNamespace
スタンプタスク・スタンプシートを一括実行
一括実行をすることで、レスポンスタイムを短縮できます。 ただし、スタンプシートの実行の過程で失敗した際には正しくリトライできる保証はありません。 実行に失敗した時に備えて GS2-Log でスタンプシートの実行ログを残しておき、カスタマーサポートの際に適切な対応ができるようにしておくことを強く推奨します。
ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
stampSheet | string | ✓ | ~ 5242880文字 | スタンプシート | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN |
Result
型 | 説明 | |
---|---|---|
taskResults | List<string> | スタンプタスクの実行結果 |
sheetResult | string | スタンプシートの実行結果レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
runStampSheetWithoutNamespace
スタンプシートを実行
ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
stampSheet | string | ✓ | ~ 5242880文字 | スタンプシート | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN | |
contextStack | string | ~ 32768文字 | リクエストコンテキスト |
Result
型 | 説明 | |
---|---|---|
result | string | レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
runStampTask
スタンプタスクを実行
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
stampTask | string | ✓ | ~ 5242880文字 | スタンプタスク | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN | |
contextStack | string | ~ 32768文字 | リクエストコンテキスト |
Result
型 | 説明 | |
---|---|---|
contextStack | string | タスクの実行結果を反映したコンテキストスタック |
result | string | レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
runStampTaskWithoutNamespace
スタンプタスクを実行
ネームスペースの指定を省略することで、 ログが記録できない・リソース溢れ処理が実行されないなどの副作用があります。
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
stampTask | string | ✓ | ~ 5242880文字 | スタンプタスク | |
keyId | string | ✓ | ~ 1024文字 | 暗号鍵GRN | |
contextStack | string | ~ 32768文字 | リクエストコンテキスト |
Result
型 | 説明 | |
---|---|---|
contextStack | string | タスクの実行結果を反映したコンテキストスタック |
result | string | レスポンス内容 |
実装例
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// New Experience ではSDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
// New Experience runs at the SDK level, so there is no need to explicitly call the API
// SDKレベルで実行されるため明示的にAPIを呼び出す必要はありません
getStampSheetResult
スタンプシートの実行結果を取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
accessToken | string | ✓ | ~ 128文字 | ユーザーID | |
transactionId | string | ✓ | 36 ~ 36文字 | スタンプシートトランザクションID |
Result
型 | 説明 | |
---|---|---|
item | EzStampSheetResult | スタンプシートの実行結果 |
実装例
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).StampSheetResult(
transactionId: "cc1985c3-54f0-4fc3-b295-dc30214284ec"
);
var item = await domain.ModelAsync();
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).StampSheetResult(
transactionId: "cc1985c3-54f0-4fc3-b295-dc30214284ec"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->StampSheetResult(
"cc1985c3-54f0-4fc3-b295-dc30214284ec" // transactionId
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
値の変更イベントハンドリング
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).StampSheetResult(
transactionId: "cc1985c3-54f0-4fc3-b295-dc30214284ec"
);
// イベントハンドリングを開始
var callbackId = domain.Subscribe(
value => {
// 値が変化した時に呼び出される
// value には変更後の値が渡ってくる
}
);
// イベントハンドリングを停止
domain.Unsubscribe(callbackId);
var domain = gs2.Distributor.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).StampSheetResult(
transactionId: "cc1985c3-54f0-4fc3-b295-dc30214284ec"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Distributor->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->StampSheetResult(
"cc1985c3-54f0-4fc3-b295-dc30214284ec" // transactionId
);
// イベントハンドリングを開始
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Distributor::Model::FStampSheetResult> value) {
// 値が変化した時に呼び出される
// value には変更後の値が渡ってくる
}
);
// イベントハンドリングを停止
Domain->Unsubscribe(CallbackId);
Warning
このイベントはSDKがもつローカルキャッシュの値が変更された時に呼び出されます。
ローカルキャッシュは SDK が持つ API の実行、または GS2-Gateway の通知を有効にした GS2-Distributor 経由でのスタンプシートの実行、または GS2-Gateway の通知を有効にした GS2-JobQueue の実行によって変化したもののみが対象となります。
そのため、これらの方法以外で値が変更されてもコールバックは呼び出されません。
イベントハンドラ
OnAutoRunStampSheetNotification
スタンプシートの自動実行が完了した際に通知
名前 | 型 | 説明 |
---|---|---|
namespaceName | string | ネームスペース名 |
transactionId | string | スタンプシートトランザクションID |
実装例
gs2.Distributor.OnAutoRunStampSheetNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var transactionId = notification.TransactionId;
};
gs2.Distributor.OnAutoRunStampSheetNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var transactionId = notification.TransactionId;
};
Gs2->Distributor->OnAutoRunStampSheetNotification().AddLambda([](const auto Notification)
{
const auto NamespaceName = Notification->NamespaceNameValue;
const auto TransactionId = Notification->TransactionIdValue;
});