Server Message API

July 4, 2026 ยท View on GitHub

This is reference about the message API of the server.

Message

Message is fixed size binary data to communicate between server and client.

There are three types of message.

  • Request: A message from a client which requires one or more replies from the server
  • Notice: A message from a client which doesn't require a reply from the server
  • Reply: A message from a server to response to the request message from a client

Communication Flow

To communicate with the server, you should follow below flow.

  1. [Client] Connect to the server by TCP
  2. [Client/Server] Complete TLS handshake if the server and client connection mode is TLS
  3. [Client] Send authentication request
  4. Message roop
    1. [Client] Send requests or notices
    2. [Server] Reply to the request with one or more messages
    3. [Client] Process reply

In below situation, the server forces to close the connection immediately without any reply.

  • Send invalid message type
  • Send not authentication request at first time after connection
  • Server internal error occured

TLS is enabled by default in the official server and client settings. Plain TCP is available only when both sides explicitly use plain connection mode.

Message Structure

All messages consist of header and body. The sizes of all messages are in less than or equals 256 bytes.

There are two types of header.

  • Request Header: A header for request message and notice message
  • Reply Header: A header for reply message

If errors occured while handling messages, the server returns only reply message header with error code.

Message Header Structure

Request/Notice Header

The size is 1 bytes.

NameTypeSizeExplanation
message_type8 bits unsigned integer1A type of message.

Options of message_type are below.

NameCategoryValue
authenticationrequest0
create_roomrequest1
list_roomrequest2
join_roomrequest3
update_room_statusnotice4
connection_testrequest5
random_matchrequest6
keep_alivenotice7

Reply Header

The size is 2 bytes.

NameTypeSizeExplanation
message_type8 bits unsigned integer1A type of message.
error_code8 bits unsigned integer1An error code.

Options of message_type are same as one used in request header.

Options of error_code are as below.

NameValueExplanation
ok0Request is processed successfully.
server_error1Server internal error.
operation_invalid2The operation is invalid in current state.
room_not_found3Indicated room is not found.
request_parameter_wrong4Wrong parameters which must be rejected in the client is passed for request.
room_password_wrong5Indicated password of room is not correct.
room_full6The number of player reaches limit.
room_permission_denied7Request is rejected because indicated room is the room which you are not host of or closed.
room_count_exceeds_limit8The number of room reaches limit.
client_already_hosting_room9Request is failed because the client is already hosting room.

Message Body Structure

Authentication Request

A request to authenticate.

Parameters

The size is 74 bytes.

NameTypeSizeExplanation
api_version16 bits unsigned integer2An API version number the client requires.
game_id24 byte length UTF-8 string24A game ID of the client.
game_version24 byte length UTF-8 string24A game version number of the client.
player_name_t24 byte length UTF-8 string24A name of player. This must not be empty.

Reply

The size is 29 bytes.

NameTypeSizeExplanation
result8 bits unsigned integer1A result of authentication.
api_version16 bits unsigned integer2An API version number of the server.
game_version24 byte length UTF-8 string24A game version the server accepts.
player_tag16 bits unsigned integer2A tag number of player to avoid duplication of player name.

Options of result are as below.

NameValueHost IdentifierExplanation
success0Authentication is succeeded.
api_version_mismatch1An API version of server is different from what the client required.
game_id_mismatch2Client game id doesn't match to the acceptable value in the server.
game_version_mismatch3Client game version doesn't match to the version the server required.

Note that authentication failure are not treated as error. If authentication is failed, the server closes the connection immediately after reply.

Error Codes

NameConditionContinuable
okThe request is processed succesfully.yes
request_parameter_wrongA player name is empty.no
operation_invalidAuthentication request is send more than twice.no

Create Room Request

A request to create room.

Parameters

The size is 84 bytes.

NameTypeSizeExplanation
password16 byte length UTF-8 string16A password of room you create. If this is empty, the room is created as a public room.
max_player_count8 bits unsigned integer1A limit of player count in the room. This must not exceeds the limit which is defined in server setting.
connection_establish_mode8 bits unsigned integer1A way how to establish P2P connection.
port_number16 bits unsigned integer2A port number which is used for game host. 49152 to 65535 is available. This is used when connection_establish_mode is builtin.
external_id64 elements byte array.64An id where clients connect using external service like Steam Networking. This is used when connection_establish_mode is not builtin. This is left justified and big endien.

Options of connection_establish_mode are as below.

NameValueHost IdentifierExplanation
builtin0port_number propertyUse builtin method.
steam1external_id property containing SteamID64 as 64bits unsigned integerUse Steam relay service.
others255external_id propertyUse other external service.

Reply

The size is 4 bytes.

NameTypeSizeExplanation
room_id32 bits unsigned integer4An id of the room created.

Error Codes

NameConditionContinuable
okThe request is processed succesfully.yes
client_already_hosting_roomFailed to host new room because the client already hosting room.yes
room_count_exceeds_limitThe number of room exceeds limit.yes
request_parameter_wrongMax player count exceeds limit. Or indicated port number is invalid.yes

List Room Request

A request to get room informations which matches to requested parameters.

Parameters

The size is 30 bytes.

NameTypeSizeExplanation
start_index16 bits unsigned integer2A start index of room data which will be replied from search results.
count16 bits unsigned integer2The number of room data which will be replied from search results.
sort_kind8 bits unsigned integer1A sort kind of result.
search_target_flags8 bits unsigned integer1A flags to indicate search target.
search_full_nameplayer_full_name24A query to search room by the room's host player name.

Options of sort_kind are as below.

NameValue
name_ascending0
name_descending1
create_datetime_ascending2
create_datetime_descending3

search_target_flags are treated as bit flags. Options are as below.

NameValue
public_room1
private_room2
open_room4
closed_room8

player_full_name is 24 bytes data as below.

NameTypeSizeExplanation
name24 byte length UTF-8 string24A name of player.
tag16 bits unsigned integer2A tag of player to avoid name duplication.

Reply

The size is 246 bytes.

NameTypeSizeExplanation
total_room_count16 bits unsigned integer2The number of rooms existing in the room group in the server.
matched_room_count16 bits unsigned integer2The number of rooms which match to the query of the room.
reply_room_count16 bits unsigned integer2The number of rooms which is included in reply messages.
room_info_listA 6 elements array of room_info240A result room info list.

room_info is 40 bytes data as below.

NameTypeSizeExplanation
room_id32 bits unsigned integer4An id of the room.
host_player_full_nameplayer_full_name24A name of player who is hosting the room.
setting_flags8 bits unsigned integer1A flags which indicate a setting of the room.
max_player_count8 bits unsigned integer1Player capability of this room.
current_player_count8 bits unsigned integer1The number of player which joins the room currently.
create_datetime64 bits unsigned integer which indicates unix time8A datetime the room created.
connection_establish_mode8 bits unsigned integer1A way how to establish P2P connection in the room.

setting_flags are treated as bit flags. Options are as below.

NameValue
public_room1
open_room2

Multiple reply messages are sent if there are more rooms than rooms one reply message can send. You can obtain the number of reply message (separation) by below expression.

separation = floor((reply.reply_room_count + 5) / 6);

Error Codes

NameConditionContinuable
okThe request is processed succesfully.yes
request_parameter_wrongsort_kind is invalid.yes

Join Room Request

A request to get the information to join the room.

Parameters

The size is 21 bytes.

NameTypeSizeExplanation
room_id32 bits unsigned integer4An id of the room you want to join.
connection_establish_mode8 bits unsigned integer1An expected way how to establish P2P connection in the room.
password16 byte length UTF-8 string16A password of the room you want to join. This is only refered when indicated room is private.

Reply

The size is 82 bytes.

NameTypeSizeExplanation
game_host_endpointendpoint18An endpoint of game host which is hosting the room you want to join.
game_host_external_id64 elements byte array.64An id to connect to the host using external service like Steam Networking. This is left justified and big endien.

game_host_endpoint is 18 bytes data as below.

NameTypeSizeExplanation
ip_addressA 16 elements array of 8 bits unsigned integer16A IP address by big endian. In IPv4, IPv4-Mapped IPv6 is used. (example, ::ffff:192.0.0.1)
port_number16 bits unsigned integer2A port number.

Error Codes

NameConditionContinuable
okThe request is processed succesfully.yes
room_not_foundIndicated room doesn't exist.yes
room_permission_deniedIndicated room is closed.yes
room_password_wrongIndicated password is wrong.yes
room_fullThe number of player reaches limit.yes
room_connection_establish_mode_mismatchConnection establish mode of the room host doesn't match expected one in the client.yes

Update Room Status Notice

A notice to inform new status of the room the client hosts.

Parameters

The size is 7 bytes.

NameTypeSizeExplanation
room_id32 bits unsigned integer4An id of the room you want to join.
status8 bits unsigned integer1A new status of the room.
is_current_player_count_changedboolean1A flag which indicates if playr count is updated.
current_player_count8 bits unsigned integer1A new player count.

Options of status are as below.

NameValue
open0
close1
remove2

Error Conditions

Notice message is ignoreed if there are some errors in processing message.

ConditionContinuable
Indicated room doesn't exist.yes
The host of indicated room is not you.yes
The number of new player count is invalid.yes
The status parameter is invalid.yes

Connection Test Request

A request to check the client is reachable from the internet.

Parameters

The size is 3 bytes.

NameTypeSizeExplanation
protocol8 bits unsigned integer1A transport prptocol to use for connection test.
port_number16 bits unsigned integer2A port number to use for connection test. 49152 to 65535 is available.

Options of prptocol are as below.

NameValue
TCP0
UDP1

Reply

The size is 1 byte.

NameTypeSizeExplanation
succeedboolean1Whether the connection test is succeeded.

Error Codes

NameConditionContinuable
okThe request is processed succesfully.yes
request_parameter_wrongIndicated protocol or port number is invalid.yes

Random Match Request

Not implemented now.

Keep Alive Notice

A notice to notice alival of the client.

Parameters

The size is 1 byte.

NameTypeSizeExplanation
dummy8 bits unsigned integer1Dummy data.

Error Conditions

The server does nothing for this notice so there are no errors.