GS2-Realtime SDK API Reference
Models
Namespace
Namespace
A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. 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.
Details
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| namespaceId | string | * | ~ 1024 chars | Namespace GRN
* Set automatically by the server | ||||||
| name | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||||||
| serverType | string (enum) enum { “relay” } | ✓ | Server Type The type of game server to provision for real-time communication. Currently supports relay mode, which provides a packet relay server that forwards messages between connected game clients.
| |||||||
| serverSpec | string (enum) enum { “realtime1.nano” } | ✓ | Server Spec The hardware specification tier for the provisioned game server. Determines the compute resources (CPU, memory) allocated to each room’s server instance. Currently supports “realtime1.nano”.
| |||||||
| createNotification | NotificationSetting | Create Notification Push Notification Setting triggered when a room finishes provisioning and is ready for connections. Since room creation is asynchronous (IP address, port, and encryption key are assigned after a short delay), this notification informs clients that the room is ready to accept connections. | ||||||||
| logSetting | LogSetting | Log Setting Configuration for outputting realtime-related operation logs to GS2-Log. When configured, actions such as room creation, connection events, and message relay activities are recorded for analysis and debugging. | ||||||||
| createdAt | long | * | Current time | Creation Timestamp Unix time, milliseconds * Set automatically by the server | ||||||
| updatedAt | long | * | Current time | Last Updated Timestamp Unix time, milliseconds * Set automatically by the server | ||||||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
TransactionSettingV2
Transaction Setting (V2)
Transaction Setting (V2) decides how the transactions issued by a Namespace are executed.
There are only two things to set:
distributorNamespaceId: the GS2-Distributor Namespace used to execute the transactionenableParallelExecution: whether the actions in a transaction run one at a time or all at once
Whichever you choose, the transaction is executed by the server the moment it is issued, and it succeeds or fails as a whole: when an action fails, the actions that already ran are undone with it and nothing is left applied. Everything else about how a transaction runs is fixed to the recommended configuration, so there is nothing else to set.
Running the actions one at a time (the default, enableParallelExecution is false) lets each action work on top of what the actions before it wrote. The actions run in verify, consume, acquire order, and this is what lets you:
- update the same row from more than one action in a single transaction, which fails when they run all at once
- read what an earlier action wrote, including from List and Query and from inside a nested transaction
- use
%{Gs2Xxx:ActionName.path[0].field}to feed the result of an earlier verify or consume action into the parameters of a later verify, consume or acquire action
In exchange, the response time is the sum of the time taken by each action, and a transaction may contain at most 20 actions. The order within each phase is decided by the action name and then by the target resource, so you cannot choose the execution order by rearranging the actions in the request, and execution stops at the first action that fails.
Running the actions all at once (enableParallelExecution is true) executes them in parallel against a single snapshot of the data, so the response time is that of the slowest single action and there is no limit on the number of actions.
In exchange, an action cannot see what the other actions wrote, and two actions that write the same row fail the transaction with database:transaction:same.resource (400), so choose this only when you can guarantee that no two actions in the same transaction write the same data. %{...} may reference only the results of an earlier phase (verify, then consume, then acquire); a reference to an action in the same phase is left unresolved, and a phase that contains %{...} waits for the earlier phases to complete, which lengthens the response time by that amount.
Transaction Setting is the obsolete setting that Transaction Setting (V2) replaces, kept for Namespaces created before Transaction Setting (V2) existed. It applies only while Transaction Setting (V2) is unset, and setting Transaction Setting (V2) supersedes it. Three behaviours it allowed are deliberately not offered here: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, and folding acquire actions into GS2-JobQueue.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| enableParallelExecution | bool | false | Whether to execute the actions in parallel instead of sequentially |
NotificationSetting
Push Notification Setting
Configuration for sending push notifications when events occur in GS2 microservices. 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 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 forward notifications to mobile push notification services when the destination device is offline. By properly utilizing mobile push notifications, you can implement a flow in which players are notified even if they exit the game during matchmaking and later return to it.
Details
| 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 | Whether to forward the notification as a mobile push notification When an attempt is made to send this notification and the destination device is offline, specify whether it should be forwarded as a 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 only if enableTransferMobileNotification is true | ||||||||
| mobileNotificationMessages | List<MobileNotificationMessage> | {enableTransferMobileNotification} == true | 0 ~ 100 items | Localized title and body used when forwarding to mobile push notifications The title and the body, per language, used when the notification is forwarded as a mobile push notification to an offline player. The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the device token, then the entry whose locale is default, and finally the first entry of the list.If this is not set, the mobile array of the notification payload is used instead, and if that is not present either, the payload itself is used as the body.* Enabled only if enableTransferMobileNotification is true | ||||||||
| enable | string (enum) enum { “Enabled”, “Disabled” } | “Enabled” | Whether to enable push notifications
|
LogSetting
Log Output Setting
Log Output Setting defines how log data is exported. This type holds the GS2-Log Namespace identifier (Namespace ID), which is 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, debugging, and other operational purposes.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log Namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
TransactionSetting
Transaction Setting
Transaction Setting is obsolete: Transaction Setting (V2) replaces it. It is kept for Namespaces created before Transaction Setting (V2) existed, applies only while Transaction Setting (V2) is unset, and should not be chosen for a new Namespace.
It exposes each part of transaction execution as a separate field – AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, asynchronous processing of acquire actions via GS2-JobQueue, and sequential execution – so combinations other than the recommended one can be built. Transaction Setting (V2) is that recommended combination expressed as a single setting. Keep using Transaction Setting only on a Namespace that already depends on a behaviour Transaction Setting (V2) does not offer: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, or folding acquire actions into GS2-JobQueue.
Details
| 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 transactions atomically * Enabled only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Enabled only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Enabled only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Enabled only if enableAtomicCommit is true | ||
| enableSequentialExecution | bool | {enableAtomicCommit} == true | false | Whether to execute the actions of an atomic commit sequentially so that multiple actions may update the same row * Enabled only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-JobQueue Namespace GRN used to execute transactions |
Room
Room
Represents a dedicated game server instance for handling real-time communication in multiplayer matches. Room creation is asynchronous: after the request, the system provisions a server and assigns an IP address, port, and encryption key once the instance is ready. Clients should wait for the create notification (or poll) before attempting to connect. The encryption key is used to establish a secure communication channel between the game clients and the relay server.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| roomId | string | * | ~ 1024 chars | Room GRN
* Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Room name Unique Room name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| ipAddress | string | ~ 128 chars | IP Address The IP address of the provisioned game server. Assigned automatically by the system after the room’s server instance is ready. Not available immediately after room creation. Maximum 128 characters. | |||
| port | int | 0 ~ 65535 | Port The listening port number of the provisioned game server. Assigned automatically along with the IP address after the server instance is ready. Range: 0-65535. | |||
| encryptionKey | string | ~ 256 chars | Encryption Key The encryption key for securing communication between game clients and the relay server. Assigned automatically along with the IP address and port after the server instance is ready. Clients must use this key to encrypt/decrypt messages sent through the relay server. Maximum 256 characters. | |||
| notificationUserIds | List<string> | [] | 0 ~ 1000 items | Notification User IDs A list of user IDs that will receive a push notification when the room finishes provisioning and is ready for connections. Typically includes the players who will participate in the real-time session so they can be notified to connect. Maximum 1,000 entries. | ||
| createdAt | long | * | Current time | Creation Timestamp Unix time, milliseconds * Set automatically by the server | ||
| updatedAt | long | * | Current time | Last Updated Timestamp Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
MobileNotificationMessage
Localized message for mobile push notification
One entry of the per-locale message list used when a notification is forwarded as a mobile push notification. Each entry holds the title and the body for one locale.
The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the Firebase device token, then the entry whose locale is default, and finally the first entry of the list.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| locale | string | ~ 32 chars | Language of the message The language this entry is for, matched against the locale registered with the Firebase device token. The value is free-form, such as ja or en. The special value default marks the fallback entry used when no entry matches the device locale. | |||
| title | string | ~ 256 chars | Title of the push notification The text displayed as the title of the mobile push notification when this entry is selected. If omitted, the subject of the notification is used. | |||
| message | string | ~ 1024 chars | Body text of the push notification The text displayed as the body of the mobile push notification when this entry is selected. |
Methods
describeNamespaces
List Namespaces
Retrieves a list of Namespaces that have been created on a per-service basis within the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of Namespaces to be acquired.
Details
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 items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Namespace> | List of Namespaces |
| 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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createNamespace
Create Namespace
You must specify detailed information including the name, description, and various settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||||||
| serverType | string (enum) enum { “relay” } | ✓ | Server Type The type of game server to provision for real-time communication. Currently supports relay mode, which provides a packet relay server that forwards messages between connected game clients.
| |||||||
| serverSpec | string (enum) enum { “realtime1.nano” } | ✓ | Server Spec The hardware specification tier for the provisioned game server. Determines the compute resources (CPU, memory) allocated to each room’s server instance. Currently supports “realtime1.nano”.
| |||||||
| createNotification | NotificationSetting | Create Notification Push Notification Setting triggered when a room finishes provisioning and is ready for connections. Since room creation is asynchronous (IP address, port, and encryption key are assigned after a short delay), this notification informs clients that the room is ready to accept connections. | ||||||||
| logSetting | LogSetting | Log Setting Configuration for outputting realtime-related operation logs to GS2-Log. When configured, actions such as room creation, connection events, and message relay activities are recorded for analysis and debugging. |
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,
TransactionSettingV2: 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)
->withTransactionSettingV2(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)
.withTransactionSettingV2(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)
.WithTransactionSettingV2(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)
.withTransactionSettingV2(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new Gs2Realtime.model.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_v2(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,
transactionSettingV2=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['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('realtime')
api_result_handler = client.create_namespace_async({
name="namespace-0001",
description=nil,
transactionSettingV2=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['errorMessage'])
end
result = api_result.result
item = result.item;getNamespaceStatus
Get Namespace Status
Get the current status of the specified Namespace. This includes whether the Namespace is active, pending, or in some other state.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |||||||
|---|---|---|---|---|---|---|---|---|
| status | string | Namespace Status
|
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
status = result.status;getNamespace
Get Namespace
Get detailed information about the specified Namespace. This includes the name, description, and other settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;updateNamespace
Update Namespace
Update the settings of the specified Namespace. You can change the description and other settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||
| description | string | ~ 1024 chars | Description | |||||||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||||||
| serverType | string (enum) enum { “relay” } | ✓ | Server Type The type of game server to provision for real-time communication. Currently supports relay mode, which provides a packet relay server that forwards messages between connected game clients.
| |||||||
| serverSpec | string (enum) enum { “realtime1.nano” } | ✓ | Server Spec The hardware specification tier for the provisioned game server. Determines the compute resources (CPU, memory) allocated to each room’s server instance. Currently supports “realtime1.nano”.
| |||||||
| createNotification | NotificationSetting | Create Notification Push Notification Setting triggered when a room finishes provisioning and is ready for connections. Since room creation is asynchronous (IP address, port, and encryption key are assigned after a short delay), this notification informs clients that the room is ready to accept connections. | ||||||||
| logSetting | LogSetting | Log Setting Configuration for outputting realtime-related operation logs to GS2-Log. When configured, actions such as room creation, connection events, and message relay activities are recorded for analysis and debugging. |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace updated |
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"),
TransactionSettingV2: 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")
->withTransactionSettingV2(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")
.withTransactionSettingV2(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")
.WithTransactionSettingV2(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")
.withTransactionSettingV2(null)
.withServerType("relay")
.withServerSpec("realtime1.nano")
.withCreateNotification(null)
.withLogSetting(new Gs2Realtime.model.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_v2(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",
transactionSettingV2=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['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('realtime')
api_result_handler = client.update_namespace_async({
namespaceName="namespace-0001",
description="description1",
transactionSettingV2=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['errorMessage'])
end
result = api_result.result
item = result.item;deleteNamespace
Delete Namespace
Delete the specified Namespace. This operation is irreversible and all data associated with the deleted Namespace will be lost.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;now
Get current time
Returns the current server timestamp for time synchronization between client and server. The timestamp is returned in Unix time (milliseconds).
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| accessToken | string | ~ 128 chars | Access token |
Result
| Type | Description | |
|---|---|---|
| timestamp | long | Current time Unix time, milliseconds |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
timestamp = result.timestamp;getServiceVersion
Get Microservice Version
Details
Request
Request parameters: None
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;describeRooms
List Rooms
Retrieves a paginated list of rooms that are currently active in the Namespace. Each room contains connection information such as IP address, port, and encryption key.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Room> | List of Room Information |
| 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['errorMessage'])
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['errorMessage'])
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.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| name | string | ✓ | ~ 128 chars | Room name Unique Room name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| notificationUserIds | List<string> | [] | 0 ~ 1000 items | Notification User IDs A list of user IDs that will receive a push notification when the room finishes provisioning and is ready for connections. Typically includes the players who will participate in the real-time session so they can be notified to connect. Maximum 1,000 entries. |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room Information |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;getRoom
Get Room Information
Retrieves detailed information about the specified room, including its IP address, port, and encryption key needed to connect to the game server.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| roomName | string | ✓ | ~ 128 chars | Room name Unique Room name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room Information |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;deleteRoom
Delete Room
Deletes the specified room and releases the associated game server resources.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| roomName | string | ✓ | ~ 128 chars | Room name Unique Room name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Room | Room Information |
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['errorMessage'])
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['errorMessage'])
end
result = api_result.result
item = result.item;