API Reference of GS2-Realtime SDK
Model
Namespace
Namespace
A namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a namespace before you can start using each service.
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| namespaceId | string | ✓ | ~ 1024 chars | Namespace GRN | ||||||
| name | string | ✓ | ~ 128 chars | Namespace name | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSetting | TransactionSetting | Transaction settings | ||||||||
| serverType | String Enum enum { “relay” } | ✓ | ~ 128 chars | Server Type
| ||||||
| serverSpec | String Enum enum { “realtime1.nano” } | ✓ | ~ 128 chars | Server Spec
| ||||||
| createNotification | NotificationSetting | Push notification when room creation is finished | ||||||||
| logSetting | LogSetting | Log output settings | ||||||||
| createdAt | long | ✓ | Now | Datetime of creation Unix time, milliseconds Automatically configured on the server | ||||||
| updatedAt | long | ✓ | Now | Datetime of last update Unix time, milliseconds Automatically configured on the server | ||||||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
Room
Room
A game server to handle real-time match communication of real-time matches. IP address, port, and encryption key will be assigned a short time after creation.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| roomId | string | ✓ | ~ 1024 chars | Room GRN | ||
| name | string | ✓ | ~ 128 chars | Room Name | ||
| ipAddress | string | ~ 128 chars | IP address | |||
| port | int | 0 ~ 65535 | Standby port | |||
| encryptionKey | string | ~ 256 chars | Encryption key | |||
| notificationUserIds | List<string> | 0 ~ 1000 items | List of user IDs to be notified when a room has been created | |||
| createdAt | long | ✓ | Now | Datetime of creation Unix time, milliseconds Automatically configured on the server | ||
| updatedAt | long | ✓ | Now | Datetime of last update Unix time, milliseconds Automatically configured on the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
NotificationSetting
Push notification settings
This is a setting for sending push notifications when an event occurs in a GS2 microservice. The push notification here refers to the processing via the WebSocket interface provided by GS2-Gateway, and is different from the push notification of a smartphone. For example, when a matchmaking is completed or a friend request is received, the GS2-Gateway can send a push notification via the WebSocket interface, and the game client can detect the change of the state.
GS2-Gateway’s push notifications can be used to send additional processing to mobile push notifications when the destination device is offline. If you use mobile push notifications well, you may be able to realize a flow in which you can notify the player by using mobile push notifications even if you end the game during matchmaking and return to the game.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gatewayNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:gateway:default” | ~ 1024 chars | GS2-Gateway namespace to use for push notifications Specify the GS2-Gateway namespace ID in GRN format starting with “grn:gs2:”. | |||||||
| enableTransferMobileNotification | bool? | false | Forwarding to mobile push notification When this notification is sent, if the destination device is offline, specify whether to forward it to mobile push notification. | |||||||||
| sound | string | {enableTransferMobileNotification} == true | ~ 1024 chars | Sound file name to be used for mobile push notifications The sound file name specified here is used when sending mobile push notifications, and you can send notifications with a special sound. * Enabled if enableTransferMobileNotification is true | ||||||||
| enable | String Enum enum { “Enabled”, “Disabled” } | ✓ | “Enabled” | ~ 128 chars | Whether to enable push notifications
|
LogSetting
Log Export Settings
Manages log data export settings. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, and debugging.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log namespace GRN to output logs |
TransactionSetting
Transaction settings
Transaction settings control how transactions are executed, their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, Distributor, batch application of script results, and asynchronous acquisition actions via JobQueue enables robust transaction management tailored to game logic.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | ✓ | false | Whether to automatically execute issued transactions on the server side | ||
| enableAtomicCommit | bool | {enableAutoRun} == true | ✓* | false | Whether to commit the execution of transactions atomically * Required if enableAutoRun is true | |
| transactionUseDistributor | bool | {enableAtomicCommit} == true | ✓* | false | Whether to execute transactions asynchronously * Required if enableAtomicCommit is true | |
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | ✓* | false | Whether to execute the commit processing of the script result asynchronously * Required if transactionUseDistributor is true | |
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | ✓* | false | Whether to use GS2-JobQueue to execute the acquire action * Required if enableAtomicCommit is true | |
| distributorNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor namespace used for transaction execution | |
| queueNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | Namespace in GS2-JobQueue used to run the transaction |
Methods
describeNamespaces
Get list of namespaces
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namePrefix | string | ~ 64 chars | Filter by namespace name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
| Type | Description | |
|---|---|---|
| items | List<Namespace> | List of Namespace |
| nextPageToken | string | Page 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 {
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->describeNamespaces(
(new DescribeNamespacesRequest())
->withNamePrefix(null)
->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()
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
List<Namespace> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
new Gs2.Gs2Realtime.Request.DescribeNamespacesRequest()
.WithNamePrefix(null)
.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()
.withNamePrefix(null)
.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_name_prefix(None)
.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({
namePrefix=nil,
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({
namePrefix=nil,
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
Create a new namespace
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSetting | TransactionSetting | Transaction settings | ||||||||
| serverType | String Enum enum { “relay” } | ✓ | ~ 128 chars | Server Type
| ||||||
| serverSpec | String Enum enum { “realtime1.nano” } | ✓ | ~ 128 chars | Server Spec
| ||||||
| createNotification | NotificationSetting | Push notification when room creation is finished | ||||||||
| logSetting | LogSetting | Log output settings |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace 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("namespace-0001"),
Description: nil,
TransactionSetting: 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:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->createNamespace(
(new CreateNamespaceRequest())
->withName("namespace-0001")
->withDescription(null)
->withTransactionSetting(null)
->withServerType("relay")
->withServerSpec("realtime1.nano")
->withCreateNotification(null)
->withLogSetting((new \Gs2\Realtime\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.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("namespace-0001")
.withDescription(null)
.withTransactionSetting(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new io.gs2.realtime.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
new Gs2.Gs2Realtime.Request.CreateNamespaceRequest()
.WithName("namespace-0001")
.WithDescription(null)
.WithTransactionSetting(null)
.WithServerType("relay")
.WithServerSpec("realtime1.nano")
.WithCreateNotification(null)
.WithLogSetting(new Gs2.Gs2Realtime.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.createNamespace(
new Gs2Realtime.CreateNamespaceRequest()
.withName("namespace-0001")
.withDescription(null)
.withTransactionSetting(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new Gs2Realtime.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.create_namespace(
realtime.CreateNamespaceRequest()
.with_name('namespace-0001')
.with_description(None)
.with_transaction_setting(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:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.create_namespace({
name="namespace-0001",
description=nil,
transactionSetting=nil,
serverType="relay",
serverSpec="realtime1.nano",
createNotification=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.create_namespace_async({
name="namespace-0001",
description=nil,
transactionSetting=nil,
serverType="relay",
serverSpec="realtime1.nano",
createNotification=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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;getNamespaceStatus
Get namespace status
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name |
Result
| Type | Description | |
|---|---|---|
| status | string |
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("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
status := result.Statususe 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->getNamespaceStatus(
(new GetNamespaceStatusRequest())
->withNamespaceName("namespace-0001")
);
$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("namespace-0001")
);
String status = result.getStatus();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
new Gs2.Gs2Realtime.Request.GetNamespaceStatusRequest()
.WithNamespaceName("namespace-0001"),
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("namespace-0001")
);
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('namespace-0001')
)
status = result.status
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.get_namespace_status({
namespaceName="namespace-0001",
})
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="namespace-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
status = result.status;getNamespace
Get namespace
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | 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.GetNamespace(
&realtime.GetNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->getNamespace(
(new GetNamespaceRequest())
->withNamespaceName("namespace-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.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("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
new Gs2.Gs2Realtime.Request.GetNamespaceRequest()
.WithNamespaceName("namespace-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.getNamespace(
new Gs2Realtime.GetNamespaceRequest()
.withNamespaceName("namespace-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_namespace(
realtime.GetNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.get_namespace({
namespaceName="namespace-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_namespace_async({
namespaceName="namespace-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;updateNamespace
Update namespace
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSetting | TransactionSetting | Transaction settings | ||||||||
| serverType | String Enum enum { “relay” } | ✓ | ~ 128 chars | Server Type
| ||||||
| serverSpec | String Enum enum { “realtime1.nano” } | ✓ | ~ 128 chars | Server Spec
| ||||||
| createNotification | NotificationSetting | Push notification when room creation is finished | ||||||||
| logSetting | LogSetting | Log output settings |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Updated 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("namespace-0001"),
Description: pointy.String("description1"),
TransactionSetting: 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:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->updateNamespace(
(new UpdateNamespaceRequest())
->withNamespaceName("namespace-0001")
->withDescription("description1")
->withTransactionSetting(null)
->withServerType("relay")
->withServerSpec("realtime1.nano")
->withCreateNotification(null)
->withLogSetting((new \Gs2\Realtime\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.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("namespace-0001")
.withDescription("description1")
.withTransactionSetting(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new io.gs2.realtime.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
new Gs2.Gs2Realtime.Request.UpdateNamespaceRequest()
.WithNamespaceName("namespace-0001")
.WithDescription("description1")
.WithTransactionSetting(null)
.WithServerType("relay")
.WithServerSpec("realtime1.nano")
.WithCreateNotification(null)
.WithLogSetting(new Gs2.Gs2Realtime.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.updateNamespace(
new Gs2Realtime.UpdateNamespaceRequest()
.withNamespaceName("namespace-0001")
.withDescription("description1")
.withTransactionSetting(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new Gs2Realtime.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.update_namespace(
realtime.UpdateNamespaceRequest()
.with_namespace_name('namespace-0001')
.with_description('description1')
.with_transaction_setting(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:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.update_namespace({
namespaceName="namespace-0001",
description="description1",
transactionSetting=nil,
serverType="relay",
serverSpec="realtime1.nano",
createNotification=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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.update_namespace_async({
namespaceName="namespace-0001",
description="description1",
transactionSetting=nil,
serverType="relay",
serverSpec="realtime1.nano",
createNotification=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-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;deleteNamespace
Delete namespace
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Deleted 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("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->deleteNamespace(
(new DeleteNamespaceRequest())
->withNamespaceName("namespace-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.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("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
new Gs2.Gs2Realtime.Request.DeleteNamespaceRequest()
.WithNamespaceName("namespace-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.deleteNamespace(
new Gs2Realtime.DeleteNamespaceRequest()
.withNamespaceName("namespace-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_namespace(
realtime.DeleteNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.delete_namespace({
namespaceName="namespace-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_namespace_async({
namespaceName="namespace-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;now
Get current time
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| accessToken | string | ~ 128 chars | Access token |
Result
| Type | Description | |
|---|---|---|
| timestamp | long | Current 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.Timestampuse 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 Gs2RealtimeRestClient(
$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;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
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;getServiceVersion
Get version of microservice
Request
| Type | Condition | Required | Default | Value Limits | Description |
|---|
Result
| Type | Description | |
|---|---|---|
| item | string | Version |
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.GetServiceVersion(
&realtime.GetServiceVersionRequest {
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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\GetServiceVersionRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2RealtimeRestClient(
$session
);
try {
$result = $client->getServiceVersion(
(new GetServiceVersionRequest())
);
$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.GetServiceVersionRequest;
import io.gs2.realtime.result.GetServiceVersionResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2RealtimeRestClient client = new Gs2RealtimeRestClient(session);
try {
GetServiceVersionResult result = client.getServiceVersion(
new GetServiceVersionRequest()
);
String item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
new Gs2.Gs2Realtime.Request.GetServiceVersionRequest(),
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.getServiceVersion(
new Gs2Realtime.GetServiceVersionRequest()
);
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_service_version(
realtime.GetServiceVersionRequest()
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.get_service_version({
})
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_service_version_async({
})
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;describeRooms
Get list of rooms
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
| Type | Description | |
|---|---|---|
| items | List<Room> | List of Room |
| nextPageToken | string | Page 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("namespace-0001"),
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->describeRooms(
(new DescribeRoomsRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withPageToken(null)
.withLimit(null)
);
List<Room> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.DescribeRoomsResult> asyncResult = null;
yield return client.DescribeRooms(
new Gs2.Gs2Realtime.Request.DescribeRoomsRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
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="namespace-0001",
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
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
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| name | string | ✓ | ~ 128 chars | Room Name | ||
| notificationUserIds | List<string> | [] | 0 ~ 1000 items | List of user IDs to be notified when a room has been created |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room |
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("namespace-0001"),
Name: pointy.String("room-0001"),
NotificationUserIds: []*string{
pointy.String("user-0001"),
pointy.String("user-0002"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->wantRoom(
(new WantRoomRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withName("room-0001")
.withNotificationUserIds(Arrays.asList(
"user-0001",
"user-0002"
))
);
Room item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.WantRoomResult> asyncResult = null;
yield return client.WantRoom(
new Gs2.Gs2Realtime.Request.WantRoomRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
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="namespace-0001",
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
Get room information
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| roomName | string | ✓ | ~ 128 chars | Room Name |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room |
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("namespace-0001"),
RoomName: pointy.String("room-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->getRoom(
(new GetRoomRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withRoomName("room-0001")
);
Room item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.GetRoomResult> asyncResult = null;
yield return client.GetRoom(
new Gs2.Gs2Realtime.Request.GetRoomRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.with_room_name('room-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.get_room({
namespaceName="namespace-0001",
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="namespace-0001",
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
Delete Room
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| roomName | string | ✓ | ~ 128 chars | Room Name |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room |
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("namespace-0001"),
RoomName: pointy.String("room-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse 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 Gs2RealtimeRestClient(
$session
);
try {
$result = $client->deleteRoom(
(new DeleteRoomRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withRoomName("room-0001")
);
Room item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2RealtimeRestClient(session);
AsyncResult<Gs2.Gs2Realtime.Result.DeleteRoomResult> asyncResult = null;
yield return client.DeleteRoom(
new Gs2.Gs2Realtime.Request.DeleteRoomRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.with_room_name('room-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('realtime')
api_result = client.delete_room({
namespaceName="namespace-0001",
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="namespace-0001",
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;