GS2-Realtime SDK API リファレンス

モデル

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。

そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。

有効化条件必須デフォルト値の制限説明
namespaceIdstring~ 1024文字ネームスペースGRN
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
serverTypeenum {
    “relay”
}
~ 128文字サーバの種類
serverSpecenum {
    “realtime1.nano”
}
~ 128文字サーバのスペック
createNotificationNotificationSettingルームの作成が終わったときのプッシュ通知
logSettingLogSettingログの出力設定
createdAtlong現在時刻作成日時 (UNIX時間 単位:ミリ秒)
updatedAtlong現在時刻最終更新日時 (UNIX時間 単位:ミリ秒)
revisionlong0~ 9223372036854775805リビジョン

serverType に指定する列挙型の定義

定義説明
relayパケットリレー

serverSpec に指定する列挙型の定義

定義説明
realtime1.nanorealtime1.nano

Room

ルーム

リアルタイム対戦の通信処理を行う為のゲームサーバー。
作成後しばらくしてから IPアドレス・ポート・暗号鍵 がアサインされます。

有効化条件必須デフォルト値の制限説明
roomIdstring~ 1024文字ルームGRN
namestring~ 128文字ルーム名
ipAddressstring~ 128文字IPアドレス
portint~ 65535待受ポート
encryptionKeystring~ 256文字暗号鍵
notificationUserIdsList<string>[]~ 1000 itemsルームの作成が終わったときに通知を受けるユーザIDリスト
createdAtlong現在時刻作成日時 (UNIX時間 単位:ミリ秒)
updatedAtlong現在時刻最終更新日時 (UNIX時間 単位:ミリ秒)
revisionlong0~ 9223372036854775805リビジョン

NotificationSetting

プッシュ通知に関する設定

GS2 のマイクロサービス内で何らかのイベントが発生した際に、プッシュ通知を送信するための設定です。
ここでいうプッシュ通知は GS2-Gateway の提供する WebSocket インターフェースを経由した処理であり、スマートフォンのプッシュ通知とは性質が異なります。
たとえば、マッチメイキングが完了した時やフレンドリクエストが届いた時など、ゲームクライアントの操作とは関係なく状態が変化した際に GS2-Gateway を経由してプッシュ通知をすることで、ゲームクライアントは状態の変化を検知することができます。

GS2-Gateway のプッシュ通知は通知先のデバイスがオフラインだった時に追加の処理としてモバイルプッシュ通知を送信できます。
モバイルプッシュ通知をうまく利用すれば、マッチメイキング中にゲームを終了しても、モバイルプッシュ通知を使用してプレイヤーに通知し、ゲームに戻ってくるフローを実現できる可能性があります。

有効化条件必須デフォルト値の制限説明
gatewayNamespaceIdstring“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024文字プッシュ通知に使用する GS2-Gateway のネームスペース
enableTransferMobileNotificationbool?falseモバイルプッシュ通知へ転送するか
soundstring{enableTransferMobileNotification} == true~ 1024文字モバイルプッシュ通知で使用するサウンドファイル名

LogSetting

ログの書き出し設定

ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。
ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。
この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。
GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。

有効化条件必須デフォルト値の制限説明
loggingNamespaceIdstring~ 1024文字ネームスペースGRN

メソッド

describeNamespaces

ネームスペースの一覧を取得

Request

有効化条件必須デフォルト値の制限説明
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Namespace>ネームスペースのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &realtime.DescribeNamespacesRequest {
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\DescribeNamespacesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.DescribeNamespacesRequest;
import io.gs2.realtime.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    List<Namespace> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.DescribeNamespacesRequest;
using Gs2.Gs2Realtime.Result.DescribeNamespacesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Realtime.Request.DescribeNamespacesRequest()
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.describeNamespaces(
        new Gs2Realtime.DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.describe_namespaces(
        realtime.DescribeNamespacesRequest()
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.describe_namespaces({
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;
client = gs2('realtime')

api_result_handler = client.describe_namespaces_async({
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

createNamespace

ネームスペースを新規作成

Request

有効化条件必須デフォルト値の制限説明
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
serverTypeenum {
    “relay”
}
~ 128文字サーバの種類
serverSpecenum {
    “realtime1.nano”
}
~ 128文字サーバのスペック
createNotificationNotificationSettingルームの作成が終わったときのプッシュ通知
logSettingLogSettingログの出力設定

serverType に指定する列挙型の定義

定義説明
relayパケットリレー

serverSpec に指定する列挙型の定義

定義説明
realtime1.nanorealtime1.nano

Result

説明
itemNamespace作成したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &realtime.CreateNamespaceRequest {
        Name: pointy.String("namespace1"),
        Description: nil,
        ServerType: pointy.String("relay"),
        ServerSpec: pointy.String("realtime1.nano"),
        CreateNotification: nil,
        LogSetting: &realtime.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\CreateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName(self::namespace1)
            ->withDescription(null)
            ->withServerType("relay")
            ->withServerSpec("realtime1.nano")
            ->withCreateNotification(null)
            ->withLogSetting((new \Gs2\Realtime\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.CreateNamespaceRequest;
import io.gs2.realtime.result.CreateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withServerType("relay")
            .withServerSpec("realtime1.nano")
            .withCreateNotification(null)
            .withLogSetting(new io.gs2.realtime.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.CreateNamespaceRequest;
using Gs2.Gs2Realtime.Result.CreateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Realtime.Request.CreateNamespaceRequest()
        .WithName("namespace1")
        .WithDescription(null)
        .WithServerType("relay")
        .WithServerSpec("realtime1.nano")
        .WithCreateNotification(null)
        .WithLogSetting(new Gs2.Gs2Realtime.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.createNamespace(
        new Gs2Realtime.CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withServerType("relay")
            .withServerSpec("realtime1.nano")
            .withCreateNotification(null)
            .withLogSetting(new Gs2Realtime.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.create_namespace(
        realtime.CreateNamespaceRequest()
            .with_name(self.hash1)
            .with_description(None)
            .with_server_type('relay')
            .with_server_spec('realtime1.nano')
            .with_create_notification(None)
            .with_log_setting(
                realtime.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.create_namespace({
    name="namespace1",
    description=nil,
    serverType="relay",
    serverSpec="realtime1.nano",
    createNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.create_namespace_async({
    name="namespace1",
    description=nil,
    serverType="relay",
    serverSpec="realtime1.nano",
    createNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getNamespaceStatus

ネームスペースの状態を取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
statusstring

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &realtime.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\GetNamespaceStatusRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName(self::namespace1)
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.GetNamespaceStatusRequest;
import io.gs2.realtime.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Realtime.Result.GetNamespaceStatusResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Realtime.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.getNamespaceStatus(
        new Gs2Realtime.GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.get_namespace_status(
        realtime.GetNamespaceStatusRequest()
            .with_namespace_name(self.hash1)
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.get_namespace_status({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
status = result.status;
client = gs2('realtime')

api_result_handler = client.get_namespace_status_async({
    namespaceName="namespace1",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
status = result.status;

getNamespace

ネームスペースを取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
itemNamespaceネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &realtime.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\GetNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.GetNamespaceRequest;
import io.gs2.realtime.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.GetNamespaceRequest;
using Gs2.Gs2Realtime.Result.GetNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Realtime.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.getNamespace(
        new Gs2Realtime.GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.get_namespace(
        realtime.GetNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.get_namespace({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.get_namespace_async({
    namespaceName="namespace1",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateNamespace

ネームスペースを更新

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
serverTypeenum {
    “relay”
}
~ 128文字サーバの種類
serverSpecenum {
    “realtime1.nano”
}
~ 128文字サーバのスペック
createNotificationNotificationSettingルームの作成が終わったときのプッシュ通知
logSettingLogSettingログの出力設定

serverType に指定する列挙型の定義

定義説明
relayパケットリレー

serverSpec に指定する列挙型の定義

定義説明
realtime1.nanorealtime1.nano

Result

説明
itemNamespace更新したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &realtime.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
        Description: pointy.String("description1"),
        ServerType: pointy.String("relay"),
        ServerSpec: pointy.String("realtime1.nano"),
        CreateNotification: nil,
        LogSetting: &realtime.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\UpdateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName(self::namespace1)
            ->withDescription("description1")
            ->withServerType("relay")
            ->withServerSpec("realtime1.nano")
            ->withCreateNotification(null)
            ->withLogSetting((new \Gs2\Realtime\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.UpdateNamespaceRequest;
import io.gs2.realtime.result.UpdateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withServerType("relay")
            .withServerSpec("realtime1.nano")
            .withCreateNotification(null)
            .withLogSetting(new io.gs2.realtime.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.UpdateNamespaceRequest;
using Gs2.Gs2Realtime.Result.UpdateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Realtime.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace1")
        .WithDescription("description1")
        .WithServerType("relay")
        .WithServerSpec("realtime1.nano")
        .WithCreateNotification(null)
        .WithLogSetting(new Gs2.Gs2Realtime.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.updateNamespace(
        new Gs2Realtime.UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withServerType("relay")
            .withServerSpec("realtime1.nano")
            .withCreateNotification(null)
            .withLogSetting(new Gs2Realtime.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.update_namespace(
        realtime.UpdateNamespaceRequest()
            .with_namespace_name(self.hash1)
            .with_description('description1')
            .with_server_type('relay')
            .with_server_spec('realtime1.nano')
            .with_create_notification(None)
            .with_log_setting(
                realtime.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.update_namespace({
    namespaceName="namespace1",
    description="description1",
    serverType="relay",
    serverSpec="realtime1.nano",
    createNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.update_namespace_async({
    namespaceName="namespace1",
    description="description1",
    serverType="relay",
    serverSpec="realtime1.nano",
    createNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteNamespace

ネームスペースを削除

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
itemNamespace削除したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &realtime.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\DeleteNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.DeleteNamespaceRequest;
import io.gs2.realtime.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.DeleteNamespaceRequest;
using Gs2.Gs2Realtime.Result.DeleteNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Realtime.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.deleteNamespace(
        new Gs2Realtime.DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.delete_namespace(
        realtime.DeleteNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.delete_namespace({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.delete_namespace_async({
    namespaceName="namespace1",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

now

現在時刻を取得

Request

有効化条件必須デフォルト値の制限説明
accessTokenstring~ 128文字ユーザーID

Result

説明
timestamplong現在時刻 (UNIX時間 単位:ミリ秒)

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.Now(
    &realtime.NowRequest {
        AccessToken: pointy.String("userId"),
    }
)
if err != nil {
    panic("error occurred")
}
timestamp := result.Timestamp
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\NowRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->now(
        (new NowRequest())
            ->withAccessToken("userId")
    );
    $timestamp = $result->getTimestamp();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.NowRequest;
import io.gs2.realtime.result.NowResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    NowResult result = client.now(
        new NowRequest()
            .withAccessToken("userId")
    );
    long timestamp = result.getTimestamp();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.NowRequest;
using Gs2.Gs2Realtime.Result.NowResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.NowResult> asyncResult = null;
yield return client.Now(
    new Gs2.Gs2Realtime.Request.NowRequest()
        .WithAccessToken("userId"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var timestamp = result.Timestamp;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.now(
        new Gs2Realtime.NowRequest()
            .withAccessToken("userId")
    );
    const timestamp = result.getTimestamp();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.now(
        realtime.NowRequest()
            .with_access_token('userId')
    )
    timestamp = result.timestamp
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.now({
    accessToken="userId",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
timestamp = result.timestamp;
client = gs2('realtime')

api_result_handler = client.now_async({
    accessToken="userId",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
timestamp = result.timestamp;

describeRooms

ルームの一覧を取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Room>ルームのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.DescribeRooms(
    &realtime.DescribeRoomsRequest {
        NamespaceName: pointy.String("namespace1"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\DescribeRoomsRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeRooms(
        (new DescribeRoomsRequest())
            ->withNamespaceName(self::namespace1)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.DescribeRoomsRequest;
import io.gs2.realtime.result.DescribeRoomsResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    DescribeRoomsResult result = client.describeRooms(
        new DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Room> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.DescribeRoomsRequest;
using Gs2.Gs2Realtime.Result.DescribeRoomsResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.DescribeRoomsResult> asyncResult = null;
yield return client.DescribeRooms(
    new Gs2.Gs2Realtime.Request.DescribeRoomsRequest()
        .WithNamespaceName("namespace1")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.describeRooms(
        new Gs2Realtime.DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.describe_rooms(
        realtime.DescribeRoomsRequest()
            .with_namespace_name(self.hash1)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.describe_rooms({
    namespaceName="namespace1",
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;
client = gs2('realtime')

api_result_handler = client.describe_rooms_async({
    namespaceName="namespace1",
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

wantRoom

ルームの作成依頼をする

ルームの作成は直ちに完了しません。
ルームの作成が完了した時に、サーバーからプッシュ通知を受け取ることが可能です。
通知を希望する場合は、プッシュ通知を送信する対象のユーザーIDのリストを notificationUserIds に指定します。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
namestring~ 128文字ルーム名
notificationUserIdsList<string>[]~ 1000 itemsルームの作成が終わったときに通知を受けるユーザIDリスト

Result

説明
itemRoomルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.WantRoom(
    &realtime.WantRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        Name: pointy.String("room-0001"),
        NotificationUserIds: []*string{
            pointy.String("user-0001"),
            pointy.String("user-0002"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\WantRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->wantRoom(
        (new WantRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withName("room-0001")
            ->withNotificationUserIds([
                "user-0001",
                "user-0002",
            ])
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.WantRoomRequest;
import io.gs2.realtime.result.WantRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    WantRoomResult result = client.wantRoom(
        new WantRoomRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withNotificationUserIds(Arrays.asList(
                "user-0001",
                "user-0002"
            ))
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.WantRoomRequest;
using Gs2.Gs2Realtime.Result.WantRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.WantRoomResult> asyncResult = null;
yield return client.WantRoom(
    new Gs2.Gs2Realtime.Request.WantRoomRequest()
        .WithNamespaceName("namespace1")
        .WithName("room-0001")
        .WithNotificationUserIds(new string[] {
            "user-0001",
            "user-0002",
        }),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.wantRoom(
        new Gs2Realtime.WantRoomRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withNotificationUserIds([
                "user-0001",
                "user-0002",
            ])
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.want_room(
        realtime.WantRoomRequest()
            .with_namespace_name(self.hash1)
            .with_name('room-0001')
            .with_notification_user_ids([
                'user-0001',
                'user-0002',
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.want_room({
    namespaceName="namespace1",
    name="room-0001",
    notificationUserIds={
        "user-0001",
        "user-0002"
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.want_room_async({
    namespaceName="namespace1",
    name="room-0001",
    notificationUserIds={
        "user-0001",
        "user-0002"
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getRoom

ルームの情報を取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestring~ 128文字ルーム名

Result

説明
itemRoomルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.GetRoom(
    &realtime.GetRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\GetRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getRoom(
        (new GetRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.GetRoomRequest;
import io.gs2.realtime.result.GetRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    GetRoomResult result = client.getRoom(
        new GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.GetRoomRequest;
using Gs2.Gs2Realtime.Result.GetRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.GetRoomResult> asyncResult = null;
yield return client.GetRoom(
    new Gs2.Gs2Realtime.Request.GetRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.getRoom(
        new Gs2Realtime.GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.get_room(
        realtime.GetRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.get_room({
    namespaceName="namespace1",
    roomName="room-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.get_room_async({
    namespaceName="namespace1",
    roomName="room-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteRoom

ルームを削除

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestring~ 128文字ルーム名

Result

説明
itemRoomルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/realtime"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := realtime.Gs2RealtimeRestClient{
    Session: &session,
}
result, err := client.DeleteRoom(
    &realtime.DeleteRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Realtime\Gs2RealtimeRestClient;
use Gs2\Realtime\Request\DeleteRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteRoom(
        (new DeleteRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.realtime.rest.Gs2RealtimeRestClient;
import io.gs2.realtime.request.DeleteRoomRequest;
import io.gs2.realtime.result.DeleteRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);

try {
    DeleteRoomResult result = client.deleteRoom(
        new DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Realtime.Gs2RealtimeRestClient;
using Gs2.Gs2Realtime.Request.DeleteRoomRequest;
using Gs2.Gs2Realtime.Result.DeleteRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2RealtimeRestClient(session);

AsyncResult<Gs2.Gs2Realtime.Result.DeleteRoomResult> asyncResult = null;
yield return client.DeleteRoom(
    new Gs2.Gs2Realtime.Request.DeleteRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Realtime from '@/gs2/realtime';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Realtime.Gs2RealtimeRestClient(session);

try {
    const result = await client.deleteRoom(
        new Gs2Realtime.DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import realtime

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = realtime.Gs2RealtimeRestClient(session)

try:
    result = client.delete_room(
        realtime.DeleteRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('realtime')

api_result = client.delete_room({
    namespaceName="namespace1",
    roomName="room-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;
client = gs2('realtime')

api_result_handler = client.delete_room_async({
    namespaceName="namespace1",
    roomName="room-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;