API Reference of GS2-Realtime SDK

Model

Namespace

Namespace

Namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. Basically, GS2 services have a layer called namespace, and different namespaces are treated as completely different data spaces, even for the same service.

Therefore, it is necessary to create a namespace before starting to use each service.

TypeConditionRequireDefaultLimitationDescription
namespaceIdstring~ 1024 charsNamespace GRN
namestring~ 32 charsNamespace name
descriptionstring~ 1024 charsdescription of Namespace
serverTypeenum [‘relay’]~ 128 charsServer Type
serverSpecenum [‘realtime1.nano’]~ 128 charsServer Spec
createNotificationNotificationSettingPush notification when room creation is finished
logSettingLogSettingLog output settings
createdAtlongDatetime of creation
updatedAtlongDatetime of last update
revisionlong0~ 9223372036854775805Revision

Room

Room

A game server for communication processing of real-time matches. IP address, port, and encryption key will be assigned a short time after creation.

TypeConditionRequireDefaultLimitationDescription
roomIdstring~ 1024 charsRoom GRN
namestring~ 128 charsRoom Name
ipAddressstring~ 128 charsIP address
portint~ 65535Standby port
encryptionKeystring~ 256 charsEncryption key
notificationUserIdsList<string>[]~ 1000 itemsList of user IDs to be notified when a room has been created
createdAtlongDatetime of creation
updatedAtlongDatetime of last update
revisionlong0~ 9223372036854775805Revision

NotificationSetting

TypeConditionRequireDefaultLimitationDescription
gatewayNamespaceIdstring~ 1024 charsNamespace GRN
enableTransferMobileNotificationbool?Forwarding to mobile push notification
soundstring~ 1024 charsSound file name to be used for mobile push notifications

LogSetting

TypeConditionRequireDefaultLimitationDescription
loggingNamespaceIdstring~ 1024 charsNamespace GRN

Methods

describeNamespaces

Get list of namespaces

Request

TypeConditionRequireDefaultLimitationDescription
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Namespace>List of Namespace
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

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;

createNamespace

Create a new namespace

Request

TypeConditionRequireDefaultLimitationDescription
namestring~ 32 charsNamespace name
descriptionstring~ 1024 charsdescription of Namespace
serverTypeenum [‘relay’]~ 128 charsServer Type
serverSpecenum [‘realtime1.nano’]~ 128 charsServer Spec
createNotificationNotificationSettingPush notification when room creation is finished
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceNamespace created

Implementation Example

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;

getNamespaceStatus

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
statusstring

Implementation Example

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;

getNamespace

Get namespace

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
itemNamespaceNamespace

Implementation Example

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;

updateNamespace

Update namespace

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
descriptionstring~ 1024 charsdescription of Namespace
serverTypeenum [‘relay’]~ 128 charsServer Type
serverSpecenum [‘realtime1.nano’]~ 128 charsServer Spec
createNotificationNotificationSettingPush notification when room creation is finished
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceUpdated namespace

Implementation Example

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;

deleteNamespace

Delete namespace

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
itemNamespaceDeleted namespace

Implementation Example

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;

now

Get current time

Request

TypeConditionRequireDefaultLimitationDescription
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
timestamplongCurrent time

Implementation Example

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;

describeRooms

Get list of rooms

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Room>List of Room
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

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;

wantRoom

Request to create a room

Room creation is not completed immediately. You can receive a push notification from the server when room creation is complete. If you wish to be notified, specify in notificationUserIds list of user IDs to whom you wish to send push notifications.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
namestring~ 128 charsRoom Name
notificationUserIdsList<string>[]~ 1000 itemsList of user IDs to be notified when a room has been created

Result

TypeDescription
itemRoomRoom

Implementation Example

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;

getRoom

Get Room

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name

Result

TypeDescription
itemRoomRoom

Implementation Example

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;

deleteRoom

Delete Room

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name

Result

TypeDescription
itemRoomRoom

Implementation Example

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;