GS2-Gateway SDK for Game Engine API リファレンス
ゲームエンジン向け GS2-SDK の モデルの仕様 と API のリファレンス
モデル
EzWebSocketSession
WebSocketSession
WebSocketセッションはGS2サーバとクライアント間の持続的な接続で、リアルタイムに双方向通信を行います。
サーバに対してクライアント側から識別子としてユーザーIDを登録します。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| connectionId | string | ✓ | ~ 128文字 | コネクションID | ||
| namespaceName | string | ✓ | ~ 128文字 | ネームスペース名 | ||
| userId | string | ✓ | ~ 128文字 | ユーザーID | 
関連するメソッド
メソッド
setUserId
サーバからプッシュ通知を受けるためのユーザーIDを設定
Request
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128文字 | ネームスペース名 | ||
| accessToken | string | ✓ | ~ 128文字 | アクセストークン | ||
| allowConcurrentAccess | bool | ✓ | true | 同時に異なるクライアントからの接続を許容するか | ||
| sessionId | string | {allowConcurrentAccess} == false | ~ 128文字 | 既存の接続が存在する場合、セッションID が同一の場合は接続を拒否しないようにするには値を設定 allowConcurrentAccess が false であれば有効 | 
Result
| 型 | 説明 | |
|---|---|---|
| item | EzWebSocketSession | 更新したWebsocketセッション | 
実装例
    var domain = gs2.Gateway.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).WebSocketSession(
    );
    var result = await domain.SetUserIdAsync(
        allowConcurrentAccess: null,
        sessionId: null
    );
    var item = await result.ModelAsync();    var domain = gs2.Gateway.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).WebSocketSession(
    );
    var future = domain.SetUserIdFuture(
        allowConcurrentAccess: null,
        sessionId: null
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;    const auto Domain = Gs2->Gateway->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->WebSocketSession(
    );
    const auto Future = Domain->SetUserId(
        // allowConcurrentAccess
        // sessionId
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();