General messages structure

Overview

Each message exchanged over the TCP socket is a JSON object adhering to the following general structure:

{
  "message_id": "string",
  "message_type": {
    // Message type content
  }
}
Name
Type
Desc

Message id

String

A unique identifier for the message, represented as a string. This ID can be used for tracking messages, correlating requests and responses, or debugging purposes.

Message type

object or string that specifies the type of the message and contains any associated data. The message_type field can be one of the following:

Message Types

ClientMessage

Represents a message sent from the client to the server. The structure includes client-specific data encapsulated within the ClientMessage object.

{
  "message_id": "string",
  "message_type": {
    "client_message": //client message contract
  }
}

ServerMessage

Represents a message sent from the server to the client. This message type contains server-specific data within the ServerMessage object.

{
  "message_id": "string",
  "message_type": {
    "server_message": //client message contract
  }
}

Ping

The server sends a heartbeat message to check the client's availability. The client must respond with a Pong message; otherwise, the server may disconnect the client.

{
  "message_id": "test",
  "message_type": "Ping"
}

Pong

A response to a Ping message, indicating that the sender is active and the connection is alive.

{
  "message_id": "test",
  "message_type": "Pong"
}

Last updated