-
Notifications
You must be signed in to change notification settings - Fork 0
Client server communication protocol
This page describes every packet transmitted between the client and the server, in every part of the application.
This page serves as a reference for the communications, so that if a developer has to rewrite a part of code that modify the client/server communication, he can refers to this page. This documentation would be hard to write in the code because that will make the code too verbose.
The packets are listed here by their headers. A packet header is an constant of the enumeration TransferType.
Each header has an associated context, expected data following the header in the packet and a direction (server->client, client->server or both). If the data is not specified for a given direction (even not specified as nothing), that means that the packet is not meant to be sent in that direction: if a packet has the field
Client -> server data: nothing
but no field
Server -> client data: (...)
that means that this packet is only sent by the client to the server, with no data.
The packets are split into several categories, depending on their contexts.
-
CHAT_PLAYER_IP- Context: used in pre-chat communications
- Meaning: getting the addresses and ports of both clients
-
Client -> server data (effectively start a chat from caller to callee):
-
std::stringthe name of the caller -
std::stringthe name of the callee -
sf::Uint16the port of the caller
-
-
Server -> client data (server response to caller):
-
sf::Uint32the address of the callee
-
-
Server -> client data (server to callee):
-
sf::Uint32the address of the caller -
sf::Uint16the port of the caller -
std::stringthe name of the callee -
std::stringthe name of the caller
-
-
CHAT_MESSAGE- Context: used during the chat communications
- Meaning: send a message to the other client
-
Client -> client data:
-
std::stringthe message to send to the other client
-
-
CHAT_QUIT- Context: used during the chat communications
- Meaning: tells that the other player wants to end the conversation
- Client -> client data: nothing
-
GAME_CONNECTION- Context: used in the home state
- Meaning: the user authenticates to the server
-
Client -> server data:
-
std::stringthe user name -
std::stringthe user password -
sf::Uint16the chat listening port
-
-
GAME_WRONG_IDENTIFIERS-
Context: response to
GAME_CONNECTION - Meaning: the user tried to authenticates but gives wrong identifiers
- Server -> client data: noting
-
Context: response to
-
GAME_ALREADY_CONNECTED-
Context: response to
GAME_CONNECTION - Meaning: the user tried to authenticates but is already connected
- Server -> client data: nothing
-
Context: response to
-
GAME_REGISTERING- Context: used in the home state
- Meaning: a new user register to the server
-
Client -> server data:
-
std::stringthe user name -
std::stringthe user password
-
-
GAME_USERNAME_NOT_AVAILABLE-
Context: response to
GAME_REGISTERING - Meaning: a new user wants to register but the user name is already taken
- Server -> client data: nothing
-
Context: response to
-
GAME_FAILED_TO_REGISTER-
Context: response to
GAME_REGISTERING -
Meaning: a new user wants to register but another error than
GAME_USERNAME_NOT_AVAILABLEoccurred - Server -> client data: nothing
-
Context: response to
-
GAME_REQUEST- Context: used in the lobby
- Meaning: a player asks to find an opponent
- Client -> server data: nothing
-
GAME_CANCEL_REQUEST- Context: used in the lobby
- Meaning: a player asks to leave the lobby
- Client -> server data: nothing
-
NEW_GAME_SERVER_CONNECTION- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_STARTING- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_PLAYER_GIVE_DECK_NAMES- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_PLAYER_ENTER_TURN- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_PLAYER_LEAVE_TURN- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_OVER- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_CARD_LIMIT_TURN_REACHED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_NOT_ENOUGH_ENERGY- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_PLAYER_ENERGY_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_PLAYER_HEALTH_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_BOARD_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_OPPONENT_BOARD_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_GRAVEYARD_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_HAND_UPDATED- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_USE_CARD- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_ATTACK_WITH_CREATURE- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
GAME_QUIT_GAME- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_DISCONNECTION- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_CHECK_CONNECTION- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_ASKS_FRIENDS- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_NEW_FRIEND- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_REMOVE_FRIEND- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
NOT_EXISTING_FRIEND- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_RESPONSE_FRIEND_REQUEST- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_GETTING_FRIEND_REQUESTS- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_ASKS_DECKS_LIST- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_EDIT_DECK- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_CREATE_DECK- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_DELETE_DECK- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_ASKS_CARDS_COLLECTION- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
PLAYER_ASKS_LADDER- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
ACKNOWLEDGE- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data:
-
FAILURE- Context:
- Meaning:
-
Client -> server data:
-
Server -> client data: