🌐 API

Lobby Server is a general-purpose WebSocket-based lobby server.

The authentication method used is JSON Web Token . The token's payload must contain the sub field with a unique identifier.

{
   sub: username
}

The client must send the token in the connection URL and in each message data object.

wss://localhost:9000/token


Ping

Ping the server.


Message

Field Type Value
event string ping
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.

Response

Field Type Value
event string pong
data json
Field Type Description
uuid string The message universally unique identifier.

Get Room

Get the user's room.


Message

Field Type Value
event string get_room
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.

Response

Field Type Value
event string get_room_response
data json
Field Type Description
uuid string The message universally unique identifier.
room json The user's room.

Get Rooms

Get the rooms.


Message

Field Type Value
event string get_rooms
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.

Response

Field Type Value
event string get_rooms_response
data json
Field Type Description
uuid string The message universally unique identifier.
rooms json[] The lobby's rooms.

Create Room

Create a new room.


Message

Field Type Value
event string create_room
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.
name string The room's name.
password string The room's password.
hidden boolean Is the room hidden?
size number Size of the room.
icon string The room's icon.

Response

Field Type Value
event string create_room_response
data json
Field Type Description
uuid string The message universally unique identifier.
room json The created room.

Join Room

Join a room.


Message

Field Type Value
event string join_room
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.
name string The room's name.
password string The room's password.

Response

Field Type Value
event string join_room_response
data json
Field Type Description
uuid string The message universally unique identifier.
room json The joined room.

Leave Room

Leave a room.


Message

Field Type Value
event string leave_room
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.

Response

Field Type Value
event string leave_room_response
data json
Field Type Description
uuid string The message universally unique identifier.
room json The left room.

Kick User

Kick a user from the room


Message

Field Type Value
event string kick_user
data json
Field Type Description
uuid string The message universally unique identifier.
token string The access token.
target string The user to kick.

Response

Field Type Value
event string kick_user_response
data json
Field Type Description
uuid string The message universally unique identifier.
user json The kicked user.
room json The kicked room.

Client Authorized

Client has been authorized.


Message

Field Type Value
event string client_authorized

Pong

Pong the client.


Message

Field Type Value
event string pong
data json
Field Type Description
uuid string The message universally unique identifier.

User Online

A user came online.


Message

Field Type Value
event string user_online
data json
Field Type Description
username string The user's username.

User Offline

A user went offline.


Message

Field Type Value
event string user_offline
data json
Field Type Description
username string The user's username.

Room Created

A room was created.


Message

Field Type Value
event string room_created
data json
Field Type Description
room json The created room.

Room Deleted

A room was deleted.


Message

Field Type Value
event string room_deleted
data json
Field Type Description
room json The deleted room.

Guest Joined Room

A guest joined a room.


Message

Field Type Value
event string guest_joined_room
data json
Field Type Description
user json The joined user.
room json The joined room.

Guest Left Room

A guest left a room.


Message

Field Type Value
event string guest_left_room
data json
Field Type Description
user json The left user.
room json The left room.

User Rejoined

A user rejoined a room.


Message

Field Type Value
event string user_rejoined
data json
Field Type Description
user json The rejoined user.
room json The rejoined room.

User Kicked

A user was kicked from a room.


Message

Field Type Value
event string user_kicked
data json
Field Type Description
user json The kicked user.
room json The kicked room.

❌ Errors

The server uses the following error schema:

Field Type Value
event string error
data json
Field Type Description
uuid string The message universally unique identifier.
code string The error code.
message string The error message.

Code Description
generic_error Generic error.
connection_error Connection error.
validation_error Validation error.
invalid_token Invalid token.
user_not_found User not found.
user_already_exists User already exists.
user_not_in_room User not in room.
user_already_in_room User already in room.
user_not_master User is not master.
room_not_found Room not found.
room_already_exists Room already exists.
room_full Room is full.
invalid_room_password Invalid room password.