Documentation index for AI agents

GS2-Inbox Deploy/CDK 레퍼런스

GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제

엔티티

Deploy 처리에서 조작 대상이 되는 리소스

Namespace

네임스페이스

네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.

따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
descriptionstring~ 1024자설명문
isAutomaticDeletingEnabledboolfalse자동 삭제
활성화하면 메시지가 개봉(읽음 처리)된 후 사용자의 메시지 목록에서 자동으로 삭제됩니다. 클라이언트의 명시적인 삭제 작업 없이 수령이 완료된 메시지를 삭제하여 수신함을 정리합니다. 비활성화된 경우, 개봉된 메시지는 수동으로 삭제할 때까지 목록에 남아 있습니다.
transactionSettingTransactionSetting트랜잭션 설정
메시지에 첨부된 보상을 지급할 때 사용되는 분산 트랜잭션 처리 설정입니다. readAcquireActions 를 가진 메시지가 개봉되면 획득 액션이 생성·실행되어 보상이 지급됩니다. 자동 실행, 원자적 커밋, 비동기 처리를 지원합니다.
receiveMessageScriptScriptSetting메시지를 수신했을 때 실행할 스크립트 설정
Script 트리거 레퍼런스 - receiveMessage
readMessageScriptScriptSetting메시지를 개봉했을 때 실행할 스크립트 설정
Script 트리거 레퍼런스 - readMessage
deleteMessageScriptScriptSetting메시지를 삭제했을 때 실행할 스크립트 설정
Script 트리거 레퍼런스 - deleteMessage
receiveNotificationNotificationSetting수신 알림
사용자의 수신함에 새 메시지가 전달되었을 때 트리거되는 푸시 알림 설정입니다. GS2-Gateway를 사용하여 게임 클라이언트에 실시간 알림을 전송하며, 폴링 없이도 UI에서 새 메시지 표시나 수신함 갱신을 수행할 수 있게 합니다.
logSettingLogSetting로그 출력 설정
메시지 조작과 관련된 API 요청 및 응답 로그를 출력하기 위한 GS2-Log 네임스페이스를 지정합니다. 감사나 디버깅 목적으로 메시지의 전달, 개봉, 보상 수령, 삭제를 추적하는 데 유용합니다.

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemNamespace생성한 네임스페이스

구현 예제

Type: GS2::Inbox::Namespace
Properties:
  Name: namespace-0001
  Description: null
  IsAutomaticDeletingEnabled: null
  TransactionSetting:
    EnableAutoRun: true
    QueueNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001
  ReceiveMessageScript: null
  ReadMessageScript: null
  DeleteMessageScript: null
  ReceiveNotification: null
  LogSetting:
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/inbox"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
inbox.NewNamespace(
    &SampleStack,
    "namespace-0001",
    inbox.NamespaceOptions{
        TransactionSetting: &core.TransactionSetting{
            QueueNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"),
        },
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Inbox\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Inbox\Model\Options\NamespaceOptions(
                transactionSetting: new \Gs2Cdk\Core\Model\TransactionSetting(
                    new \Gs2Cdk\Core\Model\TransactionSettingOptions(
                        queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    )
                ),
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.inbox.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.inbox.model.options.NamespaceOptions()
                        .withTransactionSetting(new io.gs2.cdk.core.model.TransactionSetting(
                            new io.gs2.cdk.core.model.options.TransactionSettingOptions()
                                .withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001")
                        ))
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Inbox.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Inbox.Model.Options.NamespaceOptions
            {
                transactionSetting = new Gs2Cdk.Core.Model.TransactionSetting(
                    options: new Gs2Cdk.Core.Model.TransactionSettingOptions
                    {
                        queueNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    }
                ),
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import inbox from "@/gs2cdk/inbox";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new inbox.model.Namespace(
            this,
            "namespace-0001",
            {
                transactionSetting: new core.TransactionSetting(
                    {
                        queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    }
                ),
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, inbox

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        inbox.Namespace(
            stack=self,
            name='namespace-0001',
            options=inbox.NamespaceOptions(
                transaction_setting=core.TransactionSetting(
                    options=core.TransactionSettingOptions(
                        queue_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001',
                    )
                ),
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template

TransactionSetting

트랜잭션 설정

트랜잭션 설정은 트랜잭션의 실행 방법·정합성·비동기 처리·충돌 회피 메커니즘을 제어하는 설정입니다.
자동 실행(AutoRun), 원자적 실행(AtomicCommit), GS2-Distributor를 이용한 비동기 실행, 스크립트 결과의 일괄 적용, GS2-JobQueue를 통한 입수 액션의 비동기화 등을 조합하여 게임 로직에 맞는 견고한 트랜잭션 관리를 가능하게 합니다.

타입활성화 조건필수기본값값 제한설명
enableAutoRunboolfalse발행한 트랜잭션을 서버 사이드에서 자동으로 실행할지 여부
enableAtomicCommitbool{enableAutoRun} == truefalse트랜잭션의 실행을 원자적으로 커밋할지 여부
※ enableAutoRun이(가) true 이면 활성화
transactionUseDistributorbool{enableAtomicCommit} == truefalse트랜잭션을 비동기 처리로 실행할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalse스크립트의 결과 커밋 처리를 비동기 처리로 실행할지 여부
※ transactionUseDistributor이(가) true 이면 활성화
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalse입수 액션을 실행할 때 GS2-JobQueue를 사용할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024자트랜잭션 실행에 사용하는 GS2-Distributor 네임스페이스 GRN
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024자트랜잭션 실행에 사용하는 GS2-JobQueue의 네임스페이스 GRN

ScriptSetting

스크립트 설정

GS2에서는 마이크로서비스의 이벤트에 연결하여 커스텀 스크립트를 실행할 수 있습니다.
이 모델은 스크립트 실행을 트리거하기 위한 설정을 보유합니다.

스크립트 실행 방식은 크게 두 가지로, 바로 “동기 실행"과 “비동기 실행"입니다.
동기 실행은 스크립트 실행이 완료될 때까지 처리가 블록됩니다.
대신 스크립트 실행 결과를 이용하여 API 실행을 중단시키거나 API 응답 내용을 제어할 수 있습니다.

한편, 비동기 실행에서는 스크립트 완료를 기다리기 위해 처리가 블록되는 일이 없습니다.
다만 스크립트 실행 결과를 이용하여 API 실행을 중단하거나 API 응답 내용을 변경할 수는 없습니다.
비동기 실행은 API의 응답 흐름에 영향을 주지 않으므로 원칙적으로 비동기 실행을 권장합니다.

비동기 실행에는 실행 방식이 두 가지 있으며, GS2-Script와 Amazon EventBridge가 있습니다.
Amazon EventBridge를 사용함으로써 Lua 이외의 언어로 처리를 작성할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
triggerScriptIdstring~ 1024자API 실행 시 동기적으로 실행되는 GS2-Script의 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
doneTriggerTargetType문자열 열거형
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”비동기 스크립트의 실행 방법
비동기 실행에서 사용할 스크립트의 종류를 지정합니다.
“비동기 실행의 스크립트를 사용하지 않음(none)”, “GS2-Script를 사용함(gs2_script)”, “Amazon EventBridge를 사용함(aws)” 중에서 선택할 수 있습니다.
정의설명
none없음
gs2_scriptGS2-Script
awsAmazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행할 GS2-Script 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행 스크립트를 실행하는 GS2-JobQueue 네임스페이스 GRN
비동기 실행 스크립트를 직접 실행하지 않고 GS2-JobQueue를 경유하는 경우 GS2-JobQueue의 네임스페이스GRN을 지정합니다.
GS2-JobQueue를 이용해야 할 이유는 많지 않으므로, 특별한 이유가 없다면 지정할 필요는 없습니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화

NotificationSetting

푸시 통지에 관한 설정

GS2의 마이크로서비스 내에서 어떠한 이벤트가 발생했을 때, 푸시 통지를 전송하기 위한 설정입니다.
여기서 말하는 푸시 통지란 GS2-Gateway가 제공하는 WebSocket 인터페이스를 경유하는 처리이며, 스마트폰의 푸시 통지와는 성질이 다릅니다.
예를 들어 매치메이킹이 완료되었을 때나 친구 요청이 도착했을 때 등, 게임 클라이언트의 조작과는 관계없이 상태가 변화했을 때 GS2-Gateway를 경유하여 푸시 통지를 함으로써, 게임 클라이언트는 상태 변화를 감지할 수 있습니다.

GS2-Gateway의 푸시 통지는 통지 대상 디바이스가 오프라인이었을 때 추가 처리로 모바일 푸시 통지를 전송할 수 있습니다.
모바일 푸시 통지를 잘 활용하면, 매치메이킹 중에 게임을 종료하더라도 모바일 푸시 통지를 사용하여 플레이어에게 알리고, 게임으로 복귀하도록 하는 흐름을 구현할 수 있을 가능성이 있습니다.

타입활성화 조건필수기본값값 제한설명
gatewayNamespaceIdstring“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024자푸시 통지에 사용할 GS2-Gateway의 네임스페이스
“grn:gs2:“로 시작하는 GRN 형식으로 GS2-Gateway의 네임스페이스 ID를 지정합니다.
enableTransferMobileNotificationbool?false모바일 푸시 통지로 전달할지 여부
이 통지를 전송하려 할 때, 통지 대상 디바이스가 오프라인일 경우 모바일 푸시 통지로 전달할지 여부를 지정합니다.
soundstring{enableTransferMobileNotification} == true~ 1024자모바일 푸시 통지에서 사용할 사운드 파일명
여기서 지정한 사운드 파일명은 모바일 푸시 통지를 전송할 때 사용되며, 특별한 사운드로 통지를 출력할 수 있습니다.
※ enableTransferMobileNotification이(가) true 이면 활성화
enable문자열 열거형
enum {
  “Enabled”,
  “Disabled”
}
“Enabled”푸시 통지를 활성화할지 여부
정의설명
Enabled활성화
Disabled비활성화

LogSetting

로그 출력 설정

로그 데이터의 출력 설정을 관리합니다. 이 타입은 로그 데이터를 출력하기 위해 사용되는 GS2-Log 네임스페이스의 식별자(Namespace ID)를 보관합니다.
로그 네임스페이스ID(loggingNamespaceId)에는 로그 데이터를 수집하여 저장하는 GS2-Log의 네임스페이스를 GRN 형식으로 지정합니다.
이 설정을 하면 설정된 네임스페이스 내에서 발생한 API 요청·응답 로그 데이터가 대상 GS2-Log 네임스페이스 쪽으로 출력됩니다.
GS2-Log에서는 실시간으로 로그가 제공되어 시스템 모니터링, 분석, 디버깅 등에 활용할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
loggingNamespaceIdstring
~ 1024자로그를 출력할 GS2-Log의 네임스페이스 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.

CurrentMessageMaster

현재 활성화된 글로벌 메시지 마스터 데이터

현재 네임스페이스 내에서 유효한 글로벌 메시지의 정의를 기술한 마스터 데이터입니다.
GS2에서는 마스터 데이터 관리에 JSON 형식의 파일을 사용합니다.
파일을 업로드하면 실제로 서버에 설정을 반영할 수 있습니다.

JSON 파일을 작성하는 방법으로, 관리 콘솔 내에 마스터 데이터 에디터를 제공하고 있습니다.
또한 게임 운영에 더 적합한 도구를 직접 제작하여 적절한 형식의 JSON 파일을 출력하는 방식으로도 서비스를 이용할 수 있습니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namespaceNamestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
mode문자열 열거형
enum {
  “direct”,
  “preUpload”
}
“direct”업데이트 모드
정의설명
direct마스터 데이터를 직접 업데이트
preUpload마스터 데이터를 업로드한 후 업데이트
settingsstring{mode} == “direct”
✓※
~ 5242880 바이트 (5MB)마스터 데이터
※ mode이(가) “direct” 이면 필수
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024자사전 업로드로 획득한 토큰
업로드한 마스터 데이터를 적용하기 위해 사용됩니다.
※ mode이(가) “preUpload” 이면 필수

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemCurrentMessageMaster갱신된, 현재 활성화되어 있는 글로벌 메시지의 마스터 데이터

구현 예제

Type: GS2::Inbox::CurrentMessageMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2020-03-12",
    "globalMessages": [
      {
        "name": "message-0001",
        "metadata": "hoge"
      },
      {
        "name": "message-0002",
        "metadata": "fuga",
        "readAcquireActions": [
          {
            "action": "Gs2Inventory:AcquireItemSetByUserId",
            "request": {
              "namespaceName": "namespace-0001",
              "inventoryName": "inventory-0001",
              "itemName": "item-0001",
              "acquireCount": 1,
              "expiresAt": 0,
              "createNewItemSet": false,
              "itemSetName": "",
              "userId": "#{userId}"
            }
          }
        ],
        "expiresTimeSpan":
          {
            "days": 1,
            "hours": 2,
            "minutes": 3
          }
      },
      {
        "name": "message-0003",
        "metadata": "piyo"
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/inbox"
    "github.com/gs2io/gs2-golang-cdk/inventory"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
inbox.NewNamespace(
    &SampleStack,
    "namespace-0001",
    inbox.NamespaceOptions{},
).MasterData(
    []inbox.GlobalMessage{
        inbox.NewGlobalMessage(
            "message-0001",
            "hoge",
            inbox.GlobalMessageOptions{
            },
        ),
        inbox.NewGlobalMessage(
            "message-0002",
            "fuga",
            inbox.GlobalMessageOptions{
                ReadAcquireActions: []core.AcquireAction{
                    inventory.AcquireItemSetByUserId(
                        "namespace-0001",
                        "inventory-0001",
                        "item-0001",
                        1,
                        pointy.Int64(0),
                        pointy.Bool(false),
                        pointy.String(""),
                    ),
                },
                ExpiresTimeSpan: &inbox.TimeSpan{
                    Days: 1,
                    Hours: 2,
                    Minutes: 3,
                },
            },
        ),
        inbox.NewGlobalMessage(
            "message-0003",
            "piyo",
            inbox.GlobalMessageOptions{
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Inbox\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Inbox\Model\GlobalMessage(
                    name:"message-0001",
                    metadata:"hoge"
                ),
                new \Gs2Cdk\Inbox\Model\GlobalMessage(
                    name:"message-0002",
                    metadata:"fuga",
                    options: new \Gs2Cdk\Inbox\Model\Options\GlobalMessageOptions(
                        readAcquireActions:[
                            new \Gs2Cdk\Inventory\StampSheet\AcquireItemSetByUserId(
                                namespaceName: "namespace-0001",
                                inventoryName: "inventory-0001",
                                itemName: "item-0001",
                                acquireCount: 1,
                                expiresAt: 0,
                                createNewItemSet: false,
                                itemSetName: "",
                                userId: "#{userId}"
                            ),
                        ],
                        expiresTimeSpan:new \Gs2Cdk\Inbox\Model\TimeSpan(
                            days: 1,
                            hours: 2,
                            minutes: 3,
                        )
                    )
                ),
                new \Gs2Cdk\Inbox\Model\GlobalMessage(
                    name:"message-0003",
                    metadata:"piyo"
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.inbox.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.inbox.model.GlobalMessage(
                    "message-0001",
                    "hoge"
                ),
                new io.gs2.cdk.inbox.model.GlobalMessage(
                    "message-0002",
                    "fuga",
                    new io.gs2.cdk.inbox.model.options.GlobalMessageOptions()
                        .withReadAcquireActions(Arrays.asList(
                            new io.gs2.cdk.inventory.stampSheet.AcquireItemSetByUserId(
                                "namespace-0001",
                                "inventory-0001",
                                "item-0001",
                                1L,
                                0L,
                                false,
                                "",
                                "#{userId}"
                            )
                        ))
                        .withExpiresTimeSpan(new io.gs2.cdk.inbox.model.TimeSpan(
                            1,
                            2,
                            3
                        ))
                ),
                new io.gs2.cdk.inbox.model.GlobalMessage(
                    "message-0003",
                    "piyo"
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Inbox.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Inbox.Model.GlobalMessage[] {
                new Gs2Cdk.Gs2Inbox.Model.GlobalMessage(
                    name: "message-0001",
                    metadata: "hoge"
                ),
                new Gs2Cdk.Gs2Inbox.Model.GlobalMessage(
                    name: "message-0002",
                    metadata: "fuga",
                    options: new Gs2Cdk.Gs2Inbox.Model.Options.GlobalMessageOptions
                    {
                        readAcquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
                        {
                            new Gs2Cdk.Gs2Inventory.StampSheet.AcquireItemSetByUserId(
                                namespaceName: "namespace-0001",
                                inventoryName: "inventory-0001",
                                itemName: "item-0001",
                                acquireCount: 1,
                                expiresAt: 0,
                                createNewItemSet: false,
                                itemSetName: "",
                                userId: "#{userId}"
                            )
                        },
                        expiresTimeSpan = new Gs2Cdk.Gs2Inbox.Model.TimeSpan_(
                            days: 1,
                            hours: 2,
                            minutes: 3
                        )
                    }
                ),
                new Gs2Cdk.Gs2Inbox.Model.GlobalMessage(
                    name: "message-0003",
                    metadata: "piyo"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import inbox from "@/gs2cdk/inbox";
import inventory from "@/gs2cdk/inventory";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new inbox.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new inbox.model.GlobalMessage(
                    "message-0001",
                    "hoge"
                ),
                new inbox.model.GlobalMessage(
                    "message-0002",
                    "fuga",
                    {
                        readAcquireActions: [
                            new inventory.stampSheet.AcquireItemSetByUserId(
                                "namespace-0001",
                                "inventory-0001",
                                "item-0001",
                                1,
                                0,
                                false,
                                "",
                                null,
                                "#{userId}"
                            ),
                        ],
                        expiresTimeSpan: new inbox.model.TimeSpan(
                            1,
                            2,
                            3
                        )
                    }
                ),
                new inbox.model.GlobalMessage(
                    "message-0003",
                    "piyo"
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, inbox, inventory

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        inbox.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            global_messages=[
                inbox.GlobalMessage(
                    name='message-0001',
                    metadata='hoge'
                ),
                inbox.GlobalMessage(
                    name='message-0002',
                    metadata='fuga',
                    options=inbox.GlobalMessageOptions(
                        read_acquire_actions = [
                            inventory.AcquireItemSetByUserId(
                                namespace_name='namespace-0001',
                                inventory_name='inventory-0001',
                                item_name='item-0001',
                                acquire_count=1,
                                expires_at=0,
                                create_new_item_set=False,
                                item_set_name="",
                                user_id='#{userId}'
                            ),
                        ],
                        expires_time_span = inbox.TimeSpan(
                            days=1,
                            hours=2,
                            minutes=3,
                        )
                    ),
                ),
                inbox.GlobalMessage(
                    name='message-0003',
                    metadata='piyo'
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template

GlobalMessage

글로벌 메시지

글로벌 메시지는 게임 플레이어 전체에게 메시지를 전달하는 구조입니다.

글로벌 메시지에는 유효 기간을 설정할 수 있으며, 각 게임 플레이어는 글로벌 메시지를 수신하는 처리를 실행함으로써
유효 기간 내의 글로벌 메시지 중 아직 수신하지 않은 메시지를 자신의 메시지함에 복사합니다.

타입활성화 조건필수기본값값 제한설명
globalMessageIdstring
~ 1024자전체 사용자 대상 메시지 GRN
※ 서버가 자동으로 설정
namestring
~ 128자글로벌 메시지 이름
글로벌 메시지 고유의 이름. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
metadatastring
~ 4096자메타데이터
메시지의 제목, 본문, 표시 파라미터 등을 포함하는 JSON 문자열 등, 글로벌 메시지의 내용을 나타내는 임의의 데이터입니다. 사용자가 이 글로벌 메시지를 수신하면 메타데이터는 수신함 내의 개별 메시지로 복사됩니다. GS2는 이 값을 해석하지 않습니다. 최대 4096자입니다.
readAcquireActionsList<AcquireAction>[]0 ~ 100 items개봉 시 획득 액션
이 글로벌 메시지에서 복사된 메시지를 사용자가 개봉했을 때 실행되는 획득 액션 목록입니다. 이 액션들은 메타데이터와 함께 각 사용자의 개별 메시지로 복사됩니다. 글로벌 메시지당 최대 100개의 액션입니다.
expiresTimeSpanTimeSpan유효 기한까지의 기간
사용자가 이 글로벌 메시지를 수신(복사)한 시각부터, 복사된 메시지가 만료되어 수신함에서 자동 삭제되기까지의 기간입니다. 일, 시간, 분의 조합으로 지정합니다. 유효 기한에 도달하면 메시지는 읽음 상태와 관계없이 삭제되며, 아직 받지 않은 첨부 보상도 함께 삭제됩니다.
messageReceptionPeriodEventIdstring~ 1024자메시지 수신 기간 이벤트 ID
이 글로벌 메시지를 수신(사용자의 수신함에 복사)할 수 있는 시간대를 정의하는 GS2-Schedule 이벤트의 GRN입니다. 이 기간 외에는 사용자가 글로벌 메시지 수신 작업을 실행하더라도 메시지가 전달되지 않습니다. 기간 한정 이벤트 공지나 시즌 캠페인 보상에 유용합니다.

TimeSpan

타임스팬

일, 시간, 분의 조합으로 기간을 나타냅니다. 수신 시각을 기준으로 한 메시지의 유효 기간을 정의하는 데 사용됩니다. 예를 들어 7일, 0시간, 0분의 타임스팬은 사용자가 수신한 후 정확히 1주일 후에 메시지가 만료됨을 의미합니다.

타입활성화 조건필수기본값값 제한설명
daysint00 ~ 365일수
이 타임스팬의 일수입니다. 시간, 분과 조합하여 총 기간이 계산됩니다. 최대 365일입니다.
hoursint00 ~ 24시간
이 타임스팬의 시간 수입니다. 일수, 분과 조합하여 총 기간이 계산됩니다. 최대 24시간입니다.
minutesint00 ~ 60
이 타임스팬의 분수입니다. 일수, 시간과 조합하여 총 기간이 계산됩니다. 최대 60분입니다.

AcquireAction

획득 액션

보상으로 메시지에 첨부되는 단일 획득 액션을 나타냅니다. 액션 타입(예: 인벤토리에 아이템 추가, 통화 증가)과 그 요청 파라미터로 구성됩니다. 메시지가 개봉되면 이 액션들이 트랜잭션으로 조립되어 실행되고, 사용자에게 보상이 지급됩니다.

타입활성화 조건필수기본값값 제한설명
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",
}
입수 액션에서 실행할 액션의 종류
requeststring
~ 524288자액션 실행 시 사용되는 요청의 JSON 문자열