Repository navigation
Protocol Network
To enhance security and identification, a unique token is sent to the client during the initial connection via TCP. This token must be included in each UDP message sent by the client to the server to validate the sender’s identity.
Each message sent via UDP is encapsulated in a packet structured as follows:
-
Version (1 byte): Protocol version
-
Message Type (1 byte): Identifies the message type
-
Message Type List:
-
0x00-> Login Message -
0x01-> Register Message -
0x02-> Logout Message -
0x03-> Chat Box Message -
0x04-> Create Entity Message -
0x05-> Update Component Message -
0x06-> Delete Entity Message -
0x07-> Create Room Message -
0x08-> Delete Room Message -
0x09-> Join Room Message -
0x0A-> Get room Message -
0x0B-> Leave Room Message -
0x0C-> Key Message -
0x0D-> Wrong Room Password Message -
0x0E-> Full Room Message -
0x0F-> Init Message -
0x10-> Assign Token Message
-
-
Message Type List:
-
Message ID (2 bytes): Unique identifier for the message to allow detection of duplicates or late messages.
-
Token (4 bytes): Client ID token. This token is generated by the server during the initial connection. If the message is sent by the server, the Token will be
0xFFFFFFFF. -
Payload Length (4 bytes): The length of the message data (payload), in bytes.
Contains data specific to the type of message.
-
Message Type
0x00(Login Message):-
Client -> Server:
- Username entered
- Password entered
-
Server -> Client:
- True if Client have right Username and Password.
- OR
- False if Client doesn't have right Username and Password.
-
-
Message Type
0x01(Register Message):- Client -> Server:
- Username entered to register
- Password entered to register
- Client -> Server:
-
Message Type
0x04(Update Component Message):- Server -> Client (Data depend of the Component):
-
PositionComponent- Index of Entity to update
- Position in X
- Position in Y
-
- Server -> Client (Data depend of the Component):
-
Message Type
0x0C(Key Message):- Client -> Server (Data depend of the key pressed):
-
KEY A- Int (65)
-
KEY SPACE- Int (32)
-
KEY Mouse Left Click- Int (501)
- ...
-
- Client -> Server (Data depend of the key pressed):
Of course each data are encoded in binary before to be send
Used to check data integrity. The checksum is calculated on the whole packet (header + payload) using a simple checksum.
Header (12 bytes):
-
Version:
0x01(1 byte) -
Message Type:
0x00(1 byte) (Login Message) -
Message ID:
0x0001(2 bytes) -
Token:
0xDEADBEEF(4 bytes) -
Payload Length:
0x00000009(4 bytes)
Payload (9 byte):
-
Payload:
-
0x41 0x78 0x65 0x6C(Axel as username) -
0x52 0x54 0x59 0x50 0x45(RTYPE as password)
-
Checksum (2 bytes):
- Suppose the checksum calculates to
0xF0F0.
Final Packet: 01 02 00 01 DE AD BE EF 00 00 00 09 41 78 65 6c 52 54 59 50 45 F0 F0
This packet represents a client with token 0xDEADBEEF sending a UDP message indicating he wants to connect with username Axel and password RTYPE.