GS2-Gateway SDK for Game Engine API リファレンス
モデル
EzWebSocketSession
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
connectionId | string | ✓ | | ~ 128文字 | コネクションID |
namespaceName | string | ✓ | | ~ 128文字 | ネームスペース名 |
userId | string | ✓ | | ~ 128文字 | ユーザーID |
メソッド
setUserId
サーバからプッシュ通知を受けるためのユーザーIDを設定
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 128文字 | ネームスペース名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
allowConcurrentAccess | bool | ✓ | true | | 同時に異なるクライアントからの接続を許容するか |
Result
実装例
var domain = gs2.Gateway.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).WebSocketSession(
);
var result = await domain.SetUserIdAsync(
allowConcurrentAccess: null
);
var item = await result.ModelAsync();
var domain = gs2.Gateway.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).WebSocketSession(
);
var future = domain.SetUserId(
allowConcurrentAccess: null
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
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(
AccessToken
)->WebSocketSession(
);
const auto Future = Domain->SetUserId(
nullptr // allowConcurrentAccess
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();