GS2-Realtime SDK for Game Engine API リファレンス
モデル
EzRoom
ルーム
リアルタイム対戦の通信処理を行う為のゲームサーバー。
作成後しばらくしてから IPアドレス・ポート・暗号鍵 がアサインされます。
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
name | string | ✓ | | ~ 128文字 | ルーム名 |
ipAddress | string | | | ~ 128文字 | IPアドレス |
port | int | | | ~ 65535 | 待受ポート |
encryptionKey | string | | | ~ 256文字 | 暗号鍵 |
メソッド
now
現在時刻を取得
Request
Result
実装例
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
ルームの情報を取得
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
roomName | string | ✓ | | ~ 128文字 | ルーム名 |
Result
実装例
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 item = Domain.Model();
イベントハンドラ
OnCreateNotification
ルームの作成が完了したときに使用する通知
名前 | 型 | 説明 |
---|
namespaceName | string | ネームスペース名 |
roomName | string | ルーム名 |
実装例
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;
});