Skip to main content

Lobby and WebSockets

Last updated on October 24, 2024

Overview

The AccelByte Gaming Services (AGS) WebSocket messaging protocol is a simple messaging protocol focusing on fast object-message conversion on the server side and simplicity on the client side. This protocol is a subset of the YAML data serialization language.

Basic structure

The structure supported by this protocol is a string key-value object. The keys and the values are separated by a colon followed by a white space. Objects are separated by newlines.

keyA: [valueA1valueA2valueAn]\n
keyB: [valueB1valueB2valueBn]

Each message must come with a type object defining the message type.

type:messageType\n
keyA:valueA\n
keyB:[valueB1,valueB2,valueBn,]

Date-time-based values must be represented by date time ISO-8601 up to the second field.

type:messageType\n
keyA:valueA\n
keyB:[valueB1,valueB2,valueBn,]\n
time:2018-11-09T03:51:18Z

Message types

There are three types of messages in the Lobby server implementation.

Request

A request message is a message from a client to a server. The request message type should have a "-Request" suffix. A request message must have an object ID generated by the client and the object ID must be placed after the object type. Each request must be responded to by the server with the same object ID. The object type must be at the top of any object.

type:fooRequest\n
id:878a0f51bedd4825cf46827fd1478224\n
keyA:valueA\n
keyB:[valueB1,valueB2,valueBn,]

Response

A response message is a message from a server to a client corresponding to a client's request. A response message type should have a "-Response" suffix, and the response object ID must correspond with the request. Responses must have an object code identifying a response code. Successful requests must be responded to with status 0. Unsuccessful requests must be responded to with a non-0 status code--preferably, an error event ID. When the code is non-0, the other field should be ignored.

type:fooResponse\n
id:878a0f51bedd4825cf46827fd1478224\n
code:0\n
keyA:valueA\n
keyB:[valueB1,valueB2,valueBn,]

Notification

A notification is a message sent from the server to a client without a user request. The notification message type should have a "-Notif" suffix.

type:fooNotif\n
keyA:valueA\n
keyB:[valueB1,valueB2,valueBn,]
note

Currently, there is a known issue on PlayStation where the Lobby WebSocket connection will close ungracefully after the following occurs:

  • A player opens a game on PlayStation and connects to the AccelByte Lobby WebSocket.
  • The player goes to the PlayStation home screen and opens another game.

The Lobby WebSocket will be disconnected and the AGS backend will log the disconnection with the 3121 close code.

{
"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 server usage

Friends

CommandRequest PayloadAsync Response PayloadUnrealUnity
Request Friendtype: requestFriendsRequest\n id: message123\n friendId: user123type: requestFriendsResponse\n id: message123\n code: 0Lobby::RequestFriend(FString UserId)RequestFriend(string userId, ResultCallback callback)
Request Friends By PublicIDtype: RequestFriendsByPublicID\nLobby::RequestFriendByPublicId(FString PublicId)RequestFriendByPublicId(string publicId, ResultCallback callback)
Friend request notificationtype: requestFriendsNotif\n friendId: user123SetOnIncomingRequestFriendsNotifDelegate(const FRequestFriendsNotif& OnRequestFriendsNotif)OnIncomingFriendRequest
Unfriendtype: unfriendRequest\n id: message123\n friendId: user123type: unfriendResponse\n id: message123\n code: 0Lobby::Unfriend(FString UserId)Unfriend(string userId, ResultCallback callback)
List of Friends Request V2type: ListFriendsRequestV2\n id: message123N/AN/A
List outgoing friend requesttype: listOutgoingFriendsRequest\n id: message123type: listOutgoingFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,]\nLobby::ListOutgoingFriends()ListOutgoingFriends(ResultCallback<Friends> callback)
Cancel outgoing friend requesttype: cancelFriendsRequest\n id: message123\n friendId: user123type: cancelFriendsResponse\n id: message123\n code: 0Lobby::CancelFriendRequest(FString UserId)CancelFriendRequest(string userId, ResultCallback callback)
List incoming friend requesttype: listIncomingFriendsRequest\n id: message123type: listIncomingFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,]Lobby::ListIncomingFriends()ListIncomingFriends(ResultCallback<Friends> callback)
List Incoming Friends With Timetype: ListIncomingFriendsWithTimet\nLobby::ListIncomingFriendsWithTime()ListIncomingFriendsWithTime(ResultCallback<FriendsWithTimestamp> callback)
List Outgoing Friends With Timetype: ListOutgoingFriendsWithTimet\nLobby::ListOutgoingFriendsWithTime()ListOutgoingFriendsWithTime(ResultCallback<FriendsWithTimestamp> callback)
Accept incoming friend requesttype: acceptFriendsRequest\n id: message123\n friendId: user123type: acceptFriendsResponse\n id: message123\n code: 0Lobby::AcceptFriend(FString UserId)AcceptFriend(string userId, ResultCallback callback)
Friends acceptance notificationtype: acceptFriendsNotif\n friendId: user123SetOnFriendRequestAcceptedNotifDelegate(const FAcceptFriendsNotif& OnAcceptFriendsNotif)FriendRequestAccepted
Reject incoming friend requesttype: rejectFriendsRequest\n id: message123\n friendId: user123type: rejectFriendsResponse\n id: message123\n code: 0Lobby::RejectFriend(FString UserId)RejectFriend(string userId, ResultCallback callback)
List current friendstype: listOfFriendsRequest\n id: message123type: listOfFriendsResponse\n id: message123\n code: 0\n friendsId: [user123,user456,]Lobby::LoadFriendsList()LoadFriendsList(ResultCallback<Friends> callback)
Get friendship statustype: getFriendshipStatusRequest\n id: message123\n friendId: user123type: getFriendshipStatusResponse id: message123 code: 0 friendshipStatus: 3Lobby::GetFriendshipStatus(FString UserId)GetFriendshipStatus(string userId, ResultCallback<FriendshipStatus> callback)
Unfriend notiftype: unfriendNotif\n friendId: user123SetOnUnfriendNotifDelegate(const FUnfriendNotif& OnUnfriendNotif)OnUnfriend
Cancel friend notiftype: cancelFriendsNotif\n userId: user123SetOnCancelFriendsNotifDelegate(const FCancelFriendsNotif& OnCancelFriendsNotif)FriendRequestCanceled
Reject friend notiftype: rejectFriendsNotif\n userId: user123SetOnRejectFriendsNotifDelegate(const FRejectFriendsNotif& OnRejectFriendsNotif)FriendRequestRejected

Presence

CommandRequest PayloadAsync Response PayloadUnrealUnityOSS
Set user statustype: setUserStatusRequest\n id: message123\n availability: 1\n activity: in party looking for memberstype: setUserStatusResponse\n id: message123\n code: 0Lobby::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)
Set user status v2type: setUserStatusRequestv2\nN/AN/A
Notify statustype: userStatusNotif\n userID: 123\n availability: 1\n activity: idleSetUserPresenceNotifDelegate(FFriendStatusNotif OnUserPresenceNotif)FriendsStatusChangedOnPresenceReceived
List all friends presencetype: friendsStatusRequest\n id: message123type: 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

Block Player

CommandRequest PayloadAsync Response PayloadUnrealUnity
Block playertype: blockPlayerRequest\n id: message123\n userId: user123\n blockedUserId: user456\n namespace: sdktesttype: blockPlayerResponse\n id: message123\n code: 0\n namespace: ns\n blockedUserId: user123Lobby::BlockPlayer(const FString& UserId)BlockPlayer(string userId, ResultCallback<BlockPlayerResponse> callback)
Get Blocked Playertype: GetBlockedPlayer\n*used REST API*used REST API
Block player notiftype: blockPlayerNotif userId: user123\n blockedUserId: user456\nSetBlockPlayerNotifDelegate(FBlockPlayerNotif OnBlockPlayerNotif)PlayerBlockedNotif
Unblock playertype: unblockPlayerRequest\n id: message123\n userId: user123\n unblockedUserId: user456\n namespace: nstype: unblockPlayerResponse\n id: friends-5358\n code: 0\n namespace: ns\n unblockedUserId: user456\nLobby::UnblockPlayer(const FString& UserId)UnblockPlayer(string userId, ResultCallback<UnblockPlayerResponse> callback)
Unblock player notiftype: unblockPlayerNotif userId: user123\n unblockedUserId: user456\nSetUnblockPlayerNotifDelegate(FUnblockPlayerNotif OnUnblockPlayerNotif)PlayerUnblockedNotif

Notifications

Being sent notificationtype: messageNotif\n subject: updateNotification\n from: system\n to: user123\n topic: 1111\n payload: message content 123\n sentAt: 2018-11-25T23:45:05ZSetMessageNotifDelegate(const FMessageNotif& OnNotificationMessage)OnNotificationUsed only to print log internally
Sent ban notificationtype: 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: trueSetUserBannedNotificationDelegate(FUserBannedNotification OnUserBannedNotification)UserBannedNotificationN/A
Sent unban notificationtype: 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: falseSetUserUnbannedNotificationDelegate(FUserUnbannedNotification OnUserUnbannedNotification)UserUnbannedNotificationN/A

Signaling P2P

CommandRequest PayloadAsync Response PayloadUnrealUnityOSS
Send Signalingtype: signalingP2PNotif\n id: message123\n destinationId: user123\n message: message123type: signalingP2PNotif\n id: message123\n destinationId: user123\n message: message123Lobby::SendSignalingMessage(const FString& UserId, const FString& Message)SendSignalingMessage(string userId, string message)N/A

Refresh token

CommandRequest PayloadAsync Response PayloadUnrealUnity
Refresh Tokentype: refreshTokenRequest\n id: message123\n token: token123type: refreshTokenResponse\n id: message123\n code: 0Lobby::RefreshToken(const FString& AccessToken)RefreshToken( string newAccessToken, ResultCallback callback )

Error Notifications

CommandRequest PayloadAsync Response PayloadUnrealUnity
Error Notiftype: errorNotif\n code: 429\n message: message123SetErrorNotifDelegate(FErrorNotif OnErrorNotif)ErrorNotification

More Topic

The next step is to learn about a more detailed topic on the Multiplayer Notification.