GS2-Inbox
This system enables a mechanism for messages and gifts to be delivered to players from the system and management.
Messages
read management
Messages have a read status. You can choose to keep read messages in the list or remove them from the list.
Attach Reward
Rewards can be attached to messages. Instead of marking a message as read, you can receive the reward attached to the message.
Expiration Date
Messages can have an expiration date. Messages that expire are automatically deleted.
Messages will be deleted even if you did not receive the attached reward.
Global Message
Global Message is defined as master data. The message defined here will be treated as a message for all players.
- Deliver Anniversary wishes to all players.
- Send a maintenance apology to all players.
You can use it as an in-game announcement.
It can also be used for in-game announcements, for which GS2-News may be more appropriate.
Example implementation
Sending messages
Sending messages cannot be handled by the SDK for the game engine.
Get list of received messages
var items = await gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).MessagesAsync(
).ToListAsync();
const auto It = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Messages(
);
for (auto Item : *It)
{
}
Open a message
var result = await gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Message(
messageName: "message-0001"
).ReadAsync(
);
const auto Future = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
)->Read(
);
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Delete a message
var result = await gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Message(
messageName: "message-0001"
).DeleteAsync(
);
const auto Future = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
)->Delete(
);
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Receive global messages
If there are messages in the global message that you have not yet received, Copy the messages to own inbox.
var result = await gs2.Inbox.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).ReceiveGlobalMessageAsync(
);
const auto Future = Gs2->Inbox->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Message(
"message-0001" // messageName
)->Read(
);
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Frequently Asked Questions
Can I open messages in bulk?
No you cannot, but you can call the opening API in parallel. When opening messages with rewards set in parallel, you should give due consideration to whether the reward granting process reaches the limit defined by each microservice.
For example, GS2-Inventory defines that the quantity of the same item possessed can be updated no more than three times per second. Opening 10 messages with the same item attached in parallel may exceed this limit.
In principle, no results are lost if this limit is exceeded. However, after calling the opening API, the reward granting process, which runs asynchronously, may take some time to complete.