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

ゲームエンジン向け GS2-Inbox SDK の モデルの仕様 と API のリファレンス

モデル

EzMessage

メッセージ

ゲームプレイヤー毎に用意されるメッセージボックスに届けられたメッセージデータ。

メッセージには開封状態がある他、開封時に実行する入手アクションを設定することができます。
メッセージには有効期限を設定でき、有効期限が切れたメッセージは、未読状態、開封後の既読状態にかかわらず、自動的に削除されます。
添付された報酬を受け取っていない場合でも削除されます。

有効化条件 必須 デフォルト 値の制限 説明
messageId string
~ 1024文字 メッセージ GRN
※ サーバーが自動で設定
name string
UUID ~ 36文字 メッセージ名
メッセージの一意な名前を保持します。
名前は UUID(Universally Unique Identifier)フォーマットで自動的に生成され、各メッセージを識別するために使用されます。
metadata string
~ 4096文字 メタデータ
メッセージのタイトル、本文、送信者情報、表示パラメータなどを含むJSON文字列など、メッセージの内容を表す任意のデータです。GS2はこの値を解釈せず、メッセージUIの描画のためにゲームクライアントにそのまま渡されます。最大4096文字です。
isRead bool false 既読状態
メッセージがユーザーによって開封されたかどうかを示します。メッセージが開封されると、このフラグがtrueに設定され、readAcquireActions が実行されて添付報酬が配布され、readAt タイムスタンプが記録されます。ネームスペースで isAutomaticDeletingEnabled が設定されている場合、既読後にメッセージは削除されます。
readAcquireActions List<EzAcquireAction> [] 0 ~ 100 items 開封時入手アクション
ユーザーがこのメッセージを開封した際に実行される入手アクションのリストです。アイテム、通貨、リソースなどの報酬をメッセージに添付するために使用されます。複数のアクションを組み合わせて異なる種類の報酬を同時に付与できます。メッセージあたり最大100アクションです。
receivedAt long
現在時刻 作成日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定
readAt long 0 開封日時
UNIX 時間・ミリ秒
expiresAt long 有効期限日時
UNIX 時間・ミリ秒

EzConfig

コンフィグ設定

トランザクションの変数に適用する設定値

有効化条件 必須 デフォルト 値の制限 説明
key string
~ 64文字 名前
value string ~ 51200文字

EzAcquireAction

入手アクション

報酬としてメッセージに添付される単一の入手アクションを表します。アクションタイプ(例:インベントリへのアイテム追加、通貨増加)とそのリクエストパラメータで構成されます。メッセージが開封されると、これらのアクションがトランザクションに組み立てられ、実行されてユーザーに報酬が配布されます。

有効化条件 必須 デフォルト 値の制限 説明
action 文字列列挙型
enum {
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:AcquireForceByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2Schedule:ExtendTriggerByUserId",
"Gs2Script:InvokeScript",
"Gs2SerialKey:RevertUseByUserId",
"Gs2SerialKey:IssueOnce",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
}
入手アクションで実行するアクションの種類
request string
~ 524288文字 アクション実行時に使用されるリクエストのJSON文字列

EzVerifyActionResult

検証アクションの実行結果

有効化条件 必須 デフォルト 値の制限 説明
action 文字列列挙型
enum {
"Gs2Dictionary:VerifyEntryByUserId",
"Gs2Distributor:IfExpressionByUserId",
"Gs2Distributor:AndExpressionByUserId",
"Gs2Distributor:OrExpressionByUserId",
"Gs2Enchant:VerifyRarityParameterStatusByUserId",
"Gs2Experience:VerifyRankByUserId",
"Gs2Experience:VerifyRankCapByUserId",
"Gs2Grade:VerifyGradeByUserId",
"Gs2Grade:VerifyGradeUpMaterialByUserId",
"Gs2Guild:VerifyCurrentMaximumMemberCountByGuildName",
"Gs2Guild:VerifyIncludeMemberByUserId",
"Gs2Inventory:VerifyInventoryCurrentMaxCapacityByUserId",
"Gs2Inventory:VerifyItemSetByUserId",
"Gs2Inventory:VerifyReferenceOfByUserId",
"Gs2Inventory:VerifySimpleItemByUserId",
"Gs2Inventory:VerifyBigItemByUserId",
"Gs2Limit:VerifyCounterByUserId",
"Gs2Matchmaking:VerifyIncludeParticipantByUserId",
"Gs2Mission:VerifyCompleteByUserId",
"Gs2Mission:VerifyCounterValueByUserId",
"Gs2Ranking2:VerifyGlobalRankingScoreByUserId",
"Gs2Ranking2:VerifyClusterRankingScoreByUserId",
"Gs2Ranking2:VerifySubscribeRankingScoreByUserId",
"Gs2Schedule:VerifyTriggerByUserId",
"Gs2Schedule:VerifyEventByUserId",
"Gs2SerialKey:VerifyCodeByUserId",
"Gs2Stamina:VerifyStaminaValueByUserId",
"Gs2Stamina:VerifyStaminaMaxValueByUserId",
"Gs2Stamina:VerifyStaminaRecoverIntervalMinutesByUserId",
"Gs2Stamina:VerifyStaminaRecoverValueByUserId",
"Gs2Stamina:VerifyStaminaOverflowValueByUserId",
}
検証アクションで実行するアクションの種類
verifyRequest string
~ 524288文字 アクション実行時に使用されるリクエストのJSON文字列
statusCode int 0 ~ 999 ステータスコード
verifyResult string ~ 1048576文字 結果内容

EzConsumeActionResult

消費アクションの実行結果

有効化条件 必須 デフォルト 値の制限 説明
action 文字列列挙型
enum {
"Gs2AdReward:ConsumePointByUserId",
"Gs2Dictionary:DeleteEntriesByUserId",
"Gs2Enhance:DeleteProgressByUserId",
"Gs2Exchange:DeleteAwaitByUserId",
"Gs2Experience:SubExperienceByUserId",
"Gs2Experience:SubRankCapByUserId",
"Gs2Formation:SubMoldCapacityByUserId",
"Gs2Grade:SubGradeByUserId",
"Gs2Guild:DecreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:DecreaseMaximumIdleMinutesByUserId",
"Gs2Inbox:OpenMessageByUserId",
"Gs2Inbox:DeleteMessageByUserId",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2JobQueue:DeleteJobByUserId",
"Gs2Limit:CountUpByUserId",
"Gs2LoginReward:MarkReceivedByUserId",
"Gs2Mission:ReceiveByUserId",
"Gs2Mission:BatchReceiveByUserId",
"Gs2Mission:DecreaseCounterByUserId",
"Gs2Mission:ResetCounterByUserId",
"Gs2Money:WithdrawByUserId",
"Gs2Money:RecordReceipt",
"Gs2Money2:WithdrawByUserId",
"Gs2Money2:VerifyReceiptByUserId",
"Gs2Quest:DeleteProgressByUserId",
"Gs2Ranking2:CreateGlobalRankingReceivedRewardByUserId",
"Gs2Ranking2:CreateClusterRankingReceivedRewardByUserId",
"Gs2Schedule:DeleteTriggerByUserId",
"Gs2SerialKey:UseByUserId",
"Gs2Showcase:IncrementPurchaseCountByUserId",
"Gs2SkillTree:MarkRestrainByUserId",
"Gs2Stamina:DecreaseMaxValueByUserId",
"Gs2Stamina:ConsumeStaminaByUserId",
}
消費アクションで実行するアクションの種類
consumeRequest string
~ 524288文字 アクション実行時に使用されるリクエストのJSON文字列
statusCode int 0 ~ 999 ステータスコード
consumeResult string ~ 1048576文字 結果内容

EzAcquireActionResult

入手アクションの実行結果

有効化条件 必須 デフォルト 値の制限 説明
action 文字列列挙型
enum {
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:AcquireForceByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2Schedule:ExtendTriggerByUserId",
"Gs2Script:InvokeScript",
"Gs2SerialKey:RevertUseByUserId",
"Gs2SerialKey:IssueOnce",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
}
入手アクションで実行するアクションの種類
acquireRequest string
~ 524288文字 アクション実行時に使用されるリクエストのJSON文字列
statusCode int 0 ~ 999 ステータスコード
acquireResult string ~ 1048576文字 結果内容

EzTransactionResult

トランザクション実行結果

サーバーサイドでのトランザクションの自動実行機能を利用して実行されたトランザクションの実行結果

有効化条件 必須 デフォルト 値の制限 説明
transactionId string
36 ~ 36文字 トランザクションID
verifyResults List<EzVerifyActionResult> 0 ~ 10 items 検証アクションの実行結果リスト
consumeResults List<EzConsumeActionResult> [] 0 ~ 10 items 消費アクションの実行結果リスト
acquireResults List<EzAcquireActionResult> [] 0 ~ 100 items 入手アクションの実行結果リスト

メソッド

batchRead

複数のメッセージを一括開封してまとめて報酬を受け取る

最大10件のメッセージを一度に開封し、添付されたすべての報酬を1回の操作で付与します。
指定したメッセージのいずれかがすでに開封済みの場合、エラーが返されどのメッセージも処理されません。これにより報酬の二重受け取りが確実に防止されます。
プレゼントボックス画面の「一括開封」「すべて受け取る」ボタンに使います。プレイヤーがボタン1つで保留中の報酬をまとめて受け取れます。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
messageNames List<string>
1 ~ 10 items メッセージ名リスト
gameSession GameSession
GameSession

Result

説明
items List<EzMessage> メッセージのリスト
transactionId string 発行されたトランザクションID
stampSheet string スタンプシート
stampSheetEncryptionKeyId string スタンプシートの署名計算に使用した暗号鍵GRN
autoRunStampSheet bool トランザクションの自動実行が有効か
atomicCommit bool トランザクションをアトミックにコミットするか
transaction string 発行されたトランザクション
transactionResult EzTransactionResult トランザクション実行結果

Error

このAPIには特別な例外が定義されています。
GS2-SDK for GameEngine ではゲーム内でハンドリングが必要そうなエラーは一般的な例外から派生した特殊化した例外を用意することでハンドリングしやすくしています。
一般的なエラーの種類や、ハンドリング方法は こちら のドキュメントを参考にしてください。

基底クラス 説明
MessageExpiredException NotFoundException メッセージが有効期限が切れています

実装例

try {
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var result = await domain.BatchReadAsync(
        messageNames: new List<string> {
            "message-0001",
            "message-0002",
        }
    );
} catch(Gs2.Gs2Inbox.Exception.MessageExpiredException e) {
    // Message has expired
}
    // New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
    // エラーが発生すると TransactionException がスローされます。
    // TransactionException::Retry() でリトライが可能です。
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var future = domain.BatchReadFuture(
        messageNames: new List<string> {
            "message-0001",
            "message-0002",
        }
    );
    yield return future;
    if (future.Error != null)
    {
        if (future.Error is Gs2.Gs2Inbox.Exception.MessageExpiredException)
        {
            // Message has expired
        }
        onError.Invoke(future.Error, null);
        yield break;
    }
    // New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
    // エラーが発生すると TransactionException がスローされます。
    // TransactionException::Retry() でリトライが可能です。
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto Future = Domain->BatchRead(
        []
        {
            auto v = TOptional<TArray<FString>>();
            v->Add("message-0001");
            v->Add("message-0002");
            return v;
        }() // messageNames
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        auto e = Future->GetTask().Error();
        if (e->IsChildOf(Gs2::Inbox::Error::FMessageExpiredError::Class))
        {
            // Message has expired
        }
        return false;
    }

delete

プレゼントボックスからメッセージを削除する

開封済みかどうかに関わらず、プレイヤーのプレゼントボックスからメッセージを完全に削除します。
プレゼントボックスの設定でメッセージ開封時に自動削除するように設定している場合は、手動で呼ぶ必要はありません。
ただし、自動削除が無効の場合(開封済みメッセージがプレゼントボックスに残り続ける設定)は、このAPIでプレイヤーが受信箱を整理できるようにします。
各メッセージの「削除」「破棄」ボタンに使います。たとえば、古い開封済みメッセージを不要なものとして削除するのに便利です。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
gameSession GameSession
GameSession
messageName string
UUID ~ 36文字 メッセージ名
メッセージの一意な名前を保持します。
名前は UUID(Universally Unique Identifier)フォーマットで自動的に生成され、各メッセージを識別するために使用されます。

Result

説明
item EzMessage 削除されたメッセージ

実装例

    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var result = await domain.DeleteAsync(
    );
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var future = domain.DeleteFuture(
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Message(
        "message-0001" // messageName
    );
    const auto Future = Domain->Delete(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
    const auto Result = Future->GetTask().Result();

get

特定のメッセージの詳細を取得する

プレイヤーのプレゼントボックスにある特定のメッセージの全詳細を取得します。メタデータ(タイトル、本文など)、既読状態、添付された報酬、有効期限が含まれます。
メッセージの詳細画面を表示するのに使います。たとえば「メンテナンス補填 — ご不便をおかけし申し訳ありません!お詫びにジェム100個をお送りします。[開封する]」のような画面です。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
messageName string
UUID ~ 36文字 メッセージ名
メッセージの一意な名前を保持します。
名前は UUID(Universally Unique Identifier)フォーマットで自動的に生成され、各メッセージを識別するために使用されます。
gameSession GameSession
GameSession

Result

説明
item EzMessage メッセージ

実装例

    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var item = await domain.ModelAsync();
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var future = domain.ModelFuture();
    yield return future;
    var item = future.Result;
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Message(
        "message-0001" // messageName
    );
    const auto Future = Domain->Model();
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
値の変更イベントハンドリング
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    
    // イベントハンドリングを開始
    var callbackId = domain.Subscribe(
        value => {
            // 値が変化した時に呼び出される
            // value には変更後の値が渡ってくる
        }
    );

    // イベントハンドリングを停止
    domain.Unsubscribe(callbackId);
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    
    // イベントハンドリングを開始
    var callbackId = domain.Subscribe(
        value => {
            // 値が変化した時に呼び出される
            // value には変更後の値が渡ってくる
        }
    );

    // イベントハンドリングを停止
    domain.Unsubscribe(callbackId);
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Message(
        "message-0001" // messageName
    );
    
    // イベントハンドリングを開始
    const auto CallbackId = Domain->Subscribe(
        [](TSharedPtr<Gs2::Inbox::Model::FMessage> value) {
            // 値が変化した時に呼び出される
            // value には変更後の値が渡ってくる
        }
    );

    // イベントハンドリングを停止
    Domain->Unsubscribe(CallbackId);

list

プレイヤーのプレゼントボックスにあるメッセージの一覧を取得する

プレイヤーのプレゼントボックス(ギフトボックス / 受信箱)にあるすべてのメッセージを、新しい順に取得します。
各メッセージにはプレイヤーが開封して受け取れる報酬(アイテム、通貨など)を含められます。
既読状態でフィルタリングすることもできます。たとえば、未開封のメッセージのみや開封済みのみを表示できます。
「プレゼントボックス」「ギフト」画面を構築するのに使います。たとえば「メンテナンス補填(ジェム x100)」「デイリーログインボーナス(ゴールド x500)」のようなリストに「開封」ボタンをつけて表示する画面に便利です。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
gameSession GameSession
GameSession
isRead bool 既読状態
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items List<EzMessage> メッセージのリスト
nextPageToken string リストの続きを取得するためのページトークン

実装例

    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var items = await domain.MessagesAsync(
    ).ToListAsync();
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var it = domain.Messages(
    );
    List<EzMessage> items = new List<EzMessage>();
    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->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto It = Domain->Messages(
    );
    TArray<Gs2::UE5::Inbox::Model::FEzMessagePtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }
値の変更イベントハンドリング
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    
    // イベントハンドリングを開始
    var callbackId = domain.SubscribeMessages(
        () => {
            // リストの要素が変化した時に呼び出される
        }
    );

    // イベントハンドリングを停止
    domain.UnsubscribeMessages(callbackId);
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    
    // イベントハンドリングを開始
    var callbackId = domain.SubscribeMessages(
        () => {
            // リストの要素が変化した時に呼び出される
        }
    );

    // イベントハンドリングを停止
    domain.UnsubscribeMessages(callbackId);
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    
    // イベントハンドリングを開始
    const auto CallbackId = Domain->SubscribeMessages(
        []() {
            // リストの要素が変化した時に呼び出される
        }
    );

    // イベントハンドリングを停止
    Domain->UnsubscribeMessages(CallbackId);

read

メッセージを開封して報酬を受け取る

指定したメッセージを開封し、添付された報酬(アイテム、通貨など)をプレイヤーに付与します。
メッセージは既読になり、報酬の付与が1回の操作で行われます。すでに開封済みの場合は、報酬の二重受け取りを防ぐためにエラーが返されます。
報酬が添付されていないメッセージの場合は、単純に既読としてマークされます。
プレゼントボックスの各メッセージの「開封」「受け取る」ボタンに使います。たとえば、プレイヤーが「開封」をタップすると「ジェム x100」を受け取る、といった動作です。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
messageName string
UUID ~ 36文字 メッセージ名
メッセージの一意な名前を保持します。
名前は UUID(Universally Unique Identifier)フォーマットで自動的に生成され、各メッセージを識別するために使用されます。
gameSession GameSession
GameSession

Result

説明
item EzMessage メッセージ
transactionId string 発行されたトランザクションID
stampSheet string スタンプシート
stampSheetEncryptionKeyId string スタンプシートの署名計算に使用した暗号鍵GRN
autoRunStampSheet bool トランザクションの自動実行が有効か
atomicCommit bool トランザクションをアトミックにコミットするか
transaction string 発行されたトランザクション
transactionResult EzTransactionResult トランザクション実行結果

Error

このAPIには特別な例外が定義されています。
GS2-SDK for GameEngine ではゲーム内でハンドリングが必要そうなエラーは一般的な例外から派生した特殊化した例外を用意することでハンドリングしやすくしています。
一般的なエラーの種類や、ハンドリング方法は こちら のドキュメントを参考にしてください。

基底クラス 説明
MessageExpiredException NotFoundException メッセージが有効期限が切れています

実装例

try {
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var result = await domain.ReadAsync(
    );
} catch(Gs2.Gs2Inbox.Exception.MessageExpiredException e) {
    // Message has expired
}
    // New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
    // エラーが発生すると TransactionException がスローされます。
    // TransactionException::Retry() でリトライが可能です。
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Message(
        messageName: "message-0001"
    );
    var future = domain.ReadFuture(
    );
    yield return future;
    if (future.Error != null)
    {
        if (future.Error is Gs2.Gs2Inbox.Exception.MessageExpiredException)
        {
            // Message has expired
        }
        onError.Invoke(future.Error, null);
        yield break;
    }
    // New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
    // エラーが発生すると TransactionException がスローされます。
    // TransactionException::Retry() でリトライが可能です。
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->Message(
        "message-0001" // messageName
    );
    const auto Future = Domain->Read(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        auto e = Future->GetTask().Error();
        if (e->IsChildOf(Gs2::Inbox::Error::FMessageExpiredError::Class))
        {
            // Message has expired
        }
        return false;
    }

receiveGlobalMessage

全プレイヤー宛てのメッセージを受信する

グローバルメッセージ(メンテナンス補填やイベント報酬など、全プレイヤーに一括送信されたメッセージ)を確認し、まだ受け取っていないものをプレイヤーのプレゼントボックスに届けます。
各グローバルメッセージはプレイヤーの受信箱の個別メッセージに変換されます。すでに受信済みのメッセージはスキップされるため、複数回呼んでも安全です。
プレイヤーがプレゼントボックス画面を開いた時やログイン時に呼んで、すべてのグローバルメッセージを確実に受け取れるようにしてください。
プレゼントボックスの初期化の一部として使います。メッセージ一覧を取得する前に呼ぶことで、プレイヤーがすべてのギフトを確認できるようになります。

Request

有効化条件 必須 デフォルト 値の制限 説明
namespaceName string
~ 128文字 ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
gameSession GameSession
GameSession

Result

説明
item List<EzMessage> 受信したメッセージ一覧

実装例

    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var result = await domain.ReceiveGlobalMessageAsync(
    );
    var item = await result.ModelAsync();
    var domain = gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var future = domain.ReceiveGlobalMessageFuture(
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto Future = Domain->ReceiveGlobalMessage(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();

イベントハンドラ

OnReceiveNotification

メッセージを受信した時に使用するプッシュ通知

名前 説明
namespaceName string ネームスペース名
ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。
userId string ユーザーID
messageName string メッセージ名
メッセージの一意な名前を保持します。
名前は UUID(Universally Unique Identifier)フォーマットで自動的に生成され、各メッセージを識別するために使用されます。

実装例

    gs2.Inbox.OnReceiveNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var userId = notification.UserId;
        var messageName = notification.MessageName;
    };
    gs2.Inbox.OnReceiveNotification += notification =>
    {
        var namespaceName = notification.NamespaceName;
        var userId = notification.UserId;
        var messageName = notification.MessageName;
    };
    Gs2->Inbox->OnReceiveNotification().AddLambda([](const auto Notification)
    {
        const auto NamespaceName = Notification->NamespaceNameValue;
        const auto UserId = Notification->UserIdValue;
        const auto MessageName = Notification->MessageNameValue;
    });