API Reference of GS2-Inbox SDK for Game Engine
Model
EzMessage
Message
Message data delivered to a message box prepared for each game player.
Messages have an open status and can also have a stamp sheet attached.
Messages can have an expiration date, and messages that expire are automatically deleted.
| Type | Require | Default | Limitation | Description |
---|
messageId | string | ✓ | | ~ 1024 chars | Message GRN |
name | string | ✓ | UUID | ~ 36 chars | Message Name |
metadata | string | ✓ | | ~ 4096 chars | Metadata corresponding to the content of the message |
isRead | bool | ✓ | false | | Read |
readAcquireActions | List<EzAcquireAction> | | [] | | Obtain actions to be performed upon opening |
receivedAt | long | ✓ | | | Datetime of creation |
readAt | long | ✓ | 0 | | Read date and time |
expiresAt | long | | | | Datetime of ttl |
EzConfig
| Type | Require | Default | Limitation | Description |
---|
key | string | ✓ | | ~ 64 chars | Name |
value | string | | | ~ 51200 chars | Value |
EzAcquireAction
| Type | Require | Default | Limitation | Description |
---|
action | enum [] | ✓ | | ~ 128 chars | Types of actions to be performed in the stamp sheet |
request | string | ✓ | | ~ 1048576 chars | JSON of request |
Methods
delete
Deleting a message
If you do not have the option in your gift box settings to automatically delete messages when they are opened, you must use this API to explicitly delete messages.
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
messageName | string | ✓ | UUID | ~ 36 chars | Message Name |
Result
Implementation Example
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.Delete(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
const auto Domain = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
);
const auto Future = Domain->Delete(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
get
Get Message
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
messageName | string | ✓ | UUID | ~ 36 chars | Message Name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
Result
Implementation Example
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.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
list
Get list of messages received in the gift box
Messages can be retrieved in order from the most recent message.
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
isRead | bool | | | | Read |
pageToken | string | | | ~ 1024 chars | Token specifying the position from which to start acquiring data |
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
| Type | Description |
---|
items | List<EzMessage> | List of Message |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
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(
AccessToken
);
const auto It = Domain->Messages( // isRead
);
for (auto Item : *It)
{
}
read
Read the message
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
messageName | string | ✓ | UUID | ~ 36 chars | Message Name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
Result
| Type | Description |
---|
item | EzMessage | Message |
transactionId | string | Transaction ID of the stamp sheet issued |
stampSheet | string | Stamp sheet |
stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
autoRunStampSheet | bool | Is stamp sheet auto-execution enabled? |
Implementation Example
var domain = gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Message(
messageName: "message-0001"
);
var result = await domain.ReadAsync(
);
// New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
// エラーが発生すると TransactionException がスローされます。
// TransactionException::Retry() でリトライが可能です。
// In New Experience, stamp sheets are automatically executed at the SDK level.
// If an error occurs, a TransactionException is thrown.
// you can retry with TransactionException::Retry().
var domain = gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Message(
messageName: "message-0001"
);
var future = domain.Read(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
// New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
// エラーが発生すると TransactionException がスローされます。
// TransactionException::Retry() でリトライが可能です。
// In New Experience, stamp sheets are automatically executed at the SDK level.
// If an error occurs, a TransactionException is thrown.
// you can retry with TransactionException::Retry().
const auto Domain = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
);
const auto Future = Domain->Read(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
receiveGlobalMessage
Receive global messages
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
accessToken | string | ✓ | | ~ 128 chars | User Id |
Result
Implementation Example
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.ReceiveGlobalMessage(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
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(
AccessToken
);
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 (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
Event Handler
OnReceiveNotification
Notification used when a message is received
Name | Type | Description |
---|
namespaceName | string | Namespace name |
userId | string | User Id |
messageName | string | Message Name |
Implementation Example
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;
});