API Reference of GS2-Realtime SDK for Game Engine
Model
EzRoom
Room
A game server for communication processing of real-time matches.
IP address, port, and encryption key will be assigned a short time after creation.
| Type | Require | Default | Limitation | Description |
---|
name | string | ✓ | | ~ 128 chars | Room Name |
ipAddress | string | | | ~ 128 chars | IP address |
port | int | | | ~ 65535 | Standby port |
encryptionKey | string | | | ~ 256 chars | Encryption key |
Methods
now
Get current time
Request
| Type | Require | Default | Limitation | Description |
---|
Result
| Type | Description |
---|
timestamp | long | Current time |
Implementation Example
var domain = gs2.Realtime;
var result = await domain.NowAsync(
);
var timestamp = result.Timestamp;
var domain = gs2.Realtime;
var future = domain.Now(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var timestamp = future.Result.Timestamp;
const auto Domain = Gs2->Realtime;
const auto Future = Domain->Now(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
const auto Timestamp = Result->Timestamp;
getRoom
Get room information
Request
| Type | Require | Default | Limitation | Description |
---|
namespaceName | string | ✓ | | ~ 32 chars | Namespace name |
roomName | string | ✓ | | ~ 128 chars | Room Name |
Result
Implementation Example
var domain = gs2.Realtime.Namespace(
namespaceName: "namespace-0001"
).Room(
roomName: "room-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Realtime.Namespace(
namespaceName: "namespace-0001"
).Room(
roomName: "room-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Realtime->Namespace(
"namespace-0001" // namespaceName
)->Room(
"room-0001" // roomName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Event Handler
OnCreateNotification
Notification used when room creation is complete
Name | Type | Description |
---|
namespaceName | string | Namespace name |
roomName | string | Room Name |
Implementation Example
gs2.Realtime.OnCreateNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var roomName = notification.RoomName;
};
gs2.Realtime.OnCreateNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var roomName = notification.RoomName;
};
Gs2->Realtime->OnCreateNotification().AddLambda([](const auto Notification)
{
const auto NamespaceName = Notification->NamespaceNameValue;
const auto RoomName = Notification->RoomNameValue;
});