GS2-Inbox

Present/Message box function

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 have reached their expiration date will be automatically deleted, regardless of whether they are unread or read after opening.

It 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(
    );
    TArray<Gs2::UE5::Inbox::Model::FEzMessagePtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }

Get list of unread messages only

    var items = await gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).MessagesAsync(
        isRead: false
    ).ToListAsync();
    const auto It = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Messages(
        false // isRead
    );
    TArray<Gs2::UE5::Inbox::Model::FEzMessagePtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }

Get a list of only read messages

    var items = await gs2.Inbox.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).MessagesAsync(
        isRead: true
    ).ToListAsync();
    const auto It = Gs2->Inbox->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Messages(
        true // isRead
    );
    TArray<Gs2::UE5::Inbox::Model::FEzMessagePtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }

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 (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 (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 (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.

Detailed Reference