The communication protocol used by our game engine in order to be used over network will be described on this page. First the protocol is separated into 3 parts, the signature, the opcode and the data. Every communication is ended by a CRLF
The signature is a 4 bytes long sequence composed of the ASCII characters forming the sentence BEER which would give in ASCII 66 69 69 82
Then the opcode is a 4 bytes sequence representing an unsigned integer in little endian.
Then is following the data associated to this opcode.
| Opcode | Name | Description | From | To | Arguments |
|---|---|---|---|---|---|
| 0 | Object Position | Sends the position of an object using its id | Server | Client | A 4 byte long Integer in little endian representing an id, followed by two two bytes integers representing x and y coordinates. |
| 1 | Object Rect | Sends the animation rectangle of an object | Server | Client | A 4 byte long integer in little endian representing the id, followed by four two bytes long integers representing respectively width height x y |
| 2 | New Object | Register a new Object/Component | Server | Client | A 4 byte long Integer in little endian representing an id. Followed by another integer in the same size and endian representing the object type. |
| 3 | Event | Sends an event | Client | Server | A 1 byte long integer in little endian representing the event (relative to the game) followed by arguments specifics to the project |
| 4 | Game Speed | The game speed (tps) at which the server runs | Server | Client | A 4 byte long integer in little endian representing the game speed |
| 5 | Object Removed | Removes an object from the view | Server | Client | A 4 byte long integer in little endian representing the id |
| 6 | New Player | Informs the clients of the connection of a player | Server | Client | A 1 byte long integer in little endian representing the player id |
| 7 | Player Crashed | Informs the clients of the crash of a player | Server | Client | A 1 byte long integer in little endian representing the player id |
| 8 | Leaving | Informs the server that a player is leaving | Client | Server | Nothing |
| 9 | Player Left | Informs the clients that a player left | Server | Client | A 4 byte long integer in little endian representing the id of the player entity who left |
| 10 | Welcome | A welcoming message from the server to the clients it must not be send if there is not enough place for the client in the server players it also gives the player its id | Server | Client | Nothing |
| 11 | Refused | A not so welcoming message for when there is too much users connected and the server rejects a new player | Server | Client | Nothing |
| 12 | Ready | A client message for the server to annouce that he has loaded all the sprites | Client | Server | Nothing |
| 13 | Ping | Ping that needs to be sent by the clients to the server in order to handle lag | Client/Server | Server/Client | Nothing |
| 14 | Object Informations | Any informations needed for an object to work or for an object to display. (ex: score, player pings) | Server | Client | A 4 byte long integer in little endian representing the id, followed by your informations formatted by your standard |