Lobby と WebSocket
概要
AccelByte Gaming Services (AGS) WebSocket メッセージングプロトコルは、サーバー側での高速なオブジェクトとメッセージの変換とクライアント側でのシンプルさに焦点を当てたシンプルなメッセージングプロトコルです。このプロトコルは YAML データシリアライズ言語のサブセットです。
基本構造
このプロトコルでサポートされている構造は、文字列キーと値のオブジェクトです。キーと値はコロンの後にスペースで区切られます。オブジェクトは改行で区切られます。
| keyA: [valueA1 | valueA2 | valueAn | ]\n |
|---|---|---|---|
| keyB: [valueB1 | valueB2 | valueBn | ] |
各メッセージにはメッセージタイプを定義する type オブジェクトが必要です。
| type: | messageType\n |
|---|---|
| keyA: | valueA\n |
| keyB: | [valueB1,valueB2,valueBn,] |
日時ベースの値は、秒フィールドまでの ISO-8601 日時で表す必要があります。
| type: | messageType\n |
|---|---|
| keyA: | valueA\n |
| keyB: | [valueB1,valueB2,valueBn,]\n |
| time: | 2018-11-09T03:51:18Z |
メッセージタイプ
Lobby サーバーの実装には 3 種類のメッセージがあります。
リクエスト
リクエストメッセージは、クライアントからサーバーへのメッセージです。リクエストメッセージタイプには「-Request」サフィックスを付ける必要があります。リクエストメッセージにはクライアントによって生成されたオブジェクト ID が必要で、オブジェクト ID はオブジェクトタイプの後に配置する必要があります。各リクエストには、サーバーが同じオブジェクト ID で応答する必要があります。オブジェクトタイプはオブジェクトの先頭に配置する必要があります。
| type: | fooRequest\n |
|---|---|
| id: | 878a0f51bedd4825cf46827fd1478224\n |
| keyA: | valueA\n |
| keyB: | [valueB1,valueB2,valueBn,] |
レスポンス
レスポンスメッセージは、クライアントのリクエストに対応するサーバーからクライアントへのメッセージです。レスポンスメッセージタイプには「-Response」サフィックスを付ける必要があり、レスポンスオブジェクト ID はリクエストに対応する必要があります。レスポンスにはレスポンスコードを識別するオブジェクトコードが必要です。成功したリクエストにはステータス 0 で応答する必要があります。失敗したリクエストには 0 以外のステータスコード(できればエラーイベント ID)で応答する必要があります。コードが 0 以外の場合、他のフィールドは無視する必要があります。
| type: | fooResponse\n |
|---|---|
| id: | 878a0f51bedd4825cf46827fd1478224\n |
| code: | 0\n |
| keyA: | valueA\n |
| keyB: | [valueB1,valueB2,valueBn,] |
通知
通知は、ユーザーのリクエストなしにサーバーからクライアントに送信されるメッセージです。通知メッセージタイプには「-Notif」サフィックスを付ける必要があります。
| type: | fooNotif\n |
|---|---|
| keyA: | valueA\n |
| keyB: | [valueB1,valueB2,valueBn,] |
現在、PlayStation で既知の問題があります。以下の操作が発生すると、Lobby WebSocket 接続が非正常にクローズされます:
- プレイヤーが PlayStation でゲームを開き、AccelByte Lobby WebSocket に接続します。
- プレイヤーが PlayStation ホーム画面に移動して別のゲームを開きます。
Lobby WebSocket が切断され、AGS バックエンドは 3121 クローズコードで切断をログに記録します。
{
"Code": "3121",
"CodeName": "DisconnectReaderUnexpectedEOF",
"Text": "Disconnect WS due to server-side unexpected EOF",
"Attributes": [],
"Section": "disconnect with reconnect (reader)",
"Service": "lobby disconnect (with reconnect)"
}
Lobby サーバーの使用方法
フレンズ
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity |
|---|---|---|---|---|
| フレンドリクエスト | type: requestFriendsRequest\n id: message123\n friendId: user123 | type: requestFriendsResponse\n id: message123\n code: 0 | Lobby::RequestFriend(FString UserId) | RequestFriend(string userId, ResultCallback callback) |
| 公開 ID でフレンドリクエスト | type: RequestFriendsByPublicID\n | Lobby::RequestFriendByPublicId(FString PublicId) | RequestFriendByPublicId(string publicId, ResultCallback callback) | |
| フレンドリクエスト通知 | type: requestFriendsNotif\n friendId: user123 | SetOnIncomingRequestFriendsNotifDelegate(const FRequestFriendsNotif& OnRequestFriendsNotif) | OnIncomingFriendRequest | |
| フレンド解除 | type: unfriendRequest\n id: message123\n friendId: user123 | type: unfriendResponse\n id: message123\n code: 0 | Lobby::Unfriend(FString UserId) | Unfriend(string userId, ResultCallback callback) |
| フレンドリスト V2 リクエスト | type: ListFriendsRequestV2\n id: message123 | N/A | N/A | |
| 送信済みフレンドリクエスト一覧 | type: listOutgoingFriendsRequest\n id: message123 | type: listOutgoingFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,]\n | Lobby::ListOutgoingFriends() | ListOutgoingFriends(ResultCallback<Friends> callback) |
| 送信済みフレンドリクエストのキャンセル | type: cancelFriendsRequest\n id: message123\n friendId: user123 | type: cancelFriendsResponse\n id: message123\n code: 0 | Lobby::CancelFriendRequest(FString UserId) | CancelFriendRequest(string userId, ResultCallback callback) |
| 受信済みフレンドリクエスト一覧 | type: listIncomingFriendsRequest\n id: message123 | type: listIncomingFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,] | Lobby::ListIncomingFriends() | ListIncomingFriends(ResultCallback<Friends> callback) |
| タイムスタンプ付き受信フレンド一覧 | type: ListIncomingFriendsWithTimet\n | Lobby::ListIncomingFriendsWithTime() | ListIncomingFriendsWithTime(ResultCallback<FriendsWithTimestamp> callback) | |
| タイムスタンプ付き送信フレンド一覧 | type: ListOutgoingFriendsWithTimet\n | Lobby::ListOutgoingFriendsWithTime() | ListOutgoingFriendsWithTime(ResultCallback<FriendsWithTimestamp> callback) | |
| 受信したフレンドリクエストを承認 | type: acceptFriendsRequest\n id: message123\n friendId: user123 | type: acceptFriendsResponse\n id: message123\n code: 0 | Lobby::AcceptFriend(FString UserId) | AcceptFriend(string userId, ResultCallback callback) |
| フレンドリクエスト承認通知 | type: acceptFriendsNotif\n friendId: user123 | SetOnFriendRequestAcceptedNotifDelegate(const FAcceptFriendsNotif& OnAcceptFriendsNotif) | FriendRequestAccepted | |
| 受信したフレンドリクエストを拒否 | type: rejectFriendsRequest\n id: message123\n friendId: user123 | type: rejectFriendsResponse\n id: message123\n code: 0 | Lobby::RejectFriend(FString UserId) | RejectFriend(string userId, ResultCallback callback) |
| 現在のフレンド一覧 | type: listOfFriendsRequest\n id: message123 | type: listOfFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,] | Lobby::LoadFriendsList() | LoadFriendsList(ResultCallback<Friends> callback) |
| フレンドシップ状態を取得 | type: getFriendshipStatusRequest\n id: message123\n friendId: user123 | type: getFriendshipStatusResponse id: message123 code: 0 friendshipStatus: 3 | Lobby::GetFriendshipStatus(FString UserId) | GetFriendshipStatus(string userId, ResultCallback<FriendshipStatus> callback) |
| フレンド解除通知 | type: unfriendNotif\n friendId: user123 | SetOnUnfriendNotifDelegate(const FUnfriendNotif& OnUnfriendNotif) | OnUnfriend | |
| フレンドリクエストキャンセル通知 | type: cancelFriendsNotif\n userId: user123 | SetOnCancelFriendsNotifDelegate(const FCancelFriendsNotif& OnCancelFriendsNotif) | FriendRequestCanceled | |
| フレンドリクエスト拒否通知 | type: rejectFriendsNotif\n userId: user123 | SetOnRejectFriendsNotifDelegate(const FRejectFriendsNotif& OnRejectFriendsNotif) | FriendRequestRejected |
プレゼンス
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity | OSS |
|---|---|---|---|---|---|
| ユーザーステータスの設定 | type: setUserStatusRequest\n id: message123\n availability: 1\n activity: in party looking for members | type: setUserStatusResponse\n id: message123\n code: 0 | Lobby::SendSetPresenceStatus(const EAvailability Availability , const FString& Activity) | SetUserStatus(UserStatus status, string activity, ResultCallback callback) | void FOnlinePresenceAccelByte::SetPresence(const FUniqueNetId& User, const FOnlineUserPresenceStatus& Status, const FOnPresenceTaskCompleteDelegate& Delegate) |
| ユーザーステータスの設定 v2 | type: setUserStatusRequestv2\n | N/A | N/A | ||
| ステータス通知 | type: userStatusNotif\n userID: 123\n availability: 1\n activity: idle | SetUserPresenceNotifDelegate(FFriendStatusNotif OnUserPresenceNotif) | FriendsStatusChanged | OnPresenceReceived | |
| すべてのフレンドのプレゼンス一覧 | type: friendsStatusRequest\n id: message123 | type: friendsStatusResponse\n id: message123\n code: 0\n friendsId: [uid1,uid2,uid3,]\n availability: [1,2,1,]\n activity: [playing mahjong ultra,null,in deathmatch shooter game,]\n lastSeenAt: [2018-09-30T06:42:57Z,2018-11-30T06:42:57Z,2018-10-21T06:42:57Z,] | Lobby::SendGetOnlineFriendPresenceRequest() | ListFriendsStatus(ResultCallback<FriendsStatus> callback) | N/A |
プレイヤーのブロック
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity |
|---|---|---|---|---|
| プレイヤーをブロック | type: blockPlayerRequest\n id: message123\n userId: user123\n blockedUserId: user456\n namespace: sdktest | type: blockPlayerResponse\n id: message123\n code: 0\n namespace: ns\n blockedUserId: user123 | Lobby::BlockPlayer(const FString& UserId) | BlockPlayer(string userId, ResultCallback<BlockPlayerResponse> callback) |
| ブロックされたプレイヤーを取得 | type: GetBlockedPlayer\n | *REST API を使用 | *REST API を使用 | |
| プレイヤーブロック通知 | type: blockPlayerNotif userId: user123\n blockedUserId: user456\n | SetBlockPlayerNotifDelegate(FBlockPlayerNotif OnBlockPlayerNotif) | PlayerBlockedNotif | |
| プレイヤーのブロック解除 | type: unblockPlayerRequest\n id: message123\n userId: user123\n unblockedUserId: user456\n namespace: ns | type: unblockPlayerResponse\n id: friends-5358\n code: 0\n namespace: ns\n unblockedUserId: user456\n | Lobby::UnblockPlayer(const FString& UserId) | UnblockPlayer(string userId, ResultCallback<UnblockPlayerResponse> callback) |
| プレイヤーブロック解除通知 | type: unblockPlayerNotif userId: user123\n unblockedUserId: user456\n | SetUnblockPlayerNotifDelegate(FUnblockPlayerNotif OnUnblockPlayerNotif) | PlayerUnblockedNotif |
通知
| 通知の受信 | type: messageNotif\n subject: updateNotification\n from: system\n to: user123\n topic: 1111\n payload: message content 123\n sentAt: 2018-11-25T23:45:05Z | SetMessageNotifDelegate(const FMessageNotif& OnNotificationMessage) | OnNotification | 内部的にログを出力するためにのみ使用 | |
|---|---|---|---|---|---|
| BAN 通知の送信 | type: userBannedNotification\n id: message123\n code: 12002\n userId: user123\n ban: BAN-TYPE\n reason: BAN-REASON\n endDate: 2022-05-11 16:21:36.688 +0000 UTC\n enable: true | SetUserBannedNotificationDelegate(FUserBannedNotification OnUserBannedNotification) | UserBannedNotification | N/A | |
| BAN 解除通知の送信 | type: userUnbannedNotification\n id: message123\n code: 12002\n userId: user123\n ban: BAN-TYPE\n reason: BAN-REASON\n endDate: 2022-05-11 16:21:36.688 +0000 UTC\n enable: false | SetUserUnbannedNotificationDelegate(FUserUnbannedNotification OnUserUnbannedNotification) | UserUnbannedNotification | N/A |
シグナリング P2P
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity | OSS |
|---|---|---|---|---|---|
| シグナリングの送信 | type: signalingP2PNotif\n id: message123\n destinationId: user123\n message: message123 | type: signalingP2PNotif\n id: message123\n destinationId: user123\n message: message123 | Lobby::SendSignalingMessage(const FString& UserId, const FString& Message) | SendSignalingMessage(string userId, string message) | N/A |
トークンの更新
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity |
|---|---|---|---|---|
| トークンの更新 | type: refreshTokenRequest\n id: message123\n token: token123 | type: refreshTokenResponse\n id: message123\n code: 0 | Lobby::RefreshToken(const FString& AccessToken) | RefreshToken( string newAccessToken, ResultCallback callback ) |
エラー通知
| コマンド | リクエストペイロード | 非同期レスポンスペイロード | Unreal | Unity |
|---|---|---|---|---|
| エラー通知 | type: errorNotif\n code: 429\n message: message123 | SetErrorNotifDelegate(FErrorNotif OnErrorNotif) | ErrorNotification |
次のトピック
次のステップは、マルチプレイヤー通知に関するより詳細なトピックを学ぶことです。