|
Eile Mit Weile
|
Base class for all requests that are being sent from the client to the server. More...
#include <ClientRequest.hpp>
Classes | |
| struct | BaseClassProperties |
| Holds the properties that are common to all ClientRequest subclasses. More... | |
Public Member Functions | |
| RequestType | GetType () const |
| std::string | GetReqId () const |
| std::string | GetGameId () const |
| std::string | GetPlayerId () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
Public Member Functions inherited from Serializable | |
| virtual rapidjson::Document * | ToJson () const |
Static Public Attributes | |
| static const std::unordered_map< std::string, RequestType > | _string_to_request_type |
| static const std::unordered_map< RequestType, std::string > | _request_type_to_string |
Protected Member Functions | |
| ClientRequest (const BaseClassProperties &) | |
Static Protected Member Functions | |
| static BaseClassProperties | CreateBaseClassProperties (RequestType type, std::string req_id, std::string &player_id, std::string &game_id) |
| static BaseClassProperties | ExtractBaseClassProperties (const rapidjson::Value &json) |
Protected Attributes | |
| RequestType | _type |
| std::string | _req_id |
| std::string | _player_id |
| std::string | _game_id |
Base class for all requests that are being sent from the client to the server.
It offers a function to deserialize a ClientRequest subclass from a valid json. This class uses the RequestType enum to specify the type of the request.
|
explicitprotected |
Base constructor. Used by subclasses to initialize the BaseClassProperties.
|
staticprotected |
Creates a BaseClassProperties object from the provided parameters.
|
staticprotected |
Extracts the BaseClassProperties from the provided json object.
| std::string ClientRequest::GetGameId | ( | ) | const |
Returns the unique id of the game that the request is related to.
| std::string ClientRequest::GetPlayerId | ( | ) | const |
Returns the id of the player that sent the request.
| std::string ClientRequest::GetReqId | ( | ) | const |
Returns the unique id of the request.
| RequestType ClientRequest::GetType | ( | ) | const |
Returns the type of the request.
|
overridevirtual |
Writes the ClientRequest into a json object (serialization). Note that a corresponding FromJson function is defined by the children of this base class.
Implements Serializable.
Reimplemented in join_game_request, move_figure_request, skip_turn_request, start_game_request, and throw_dice_request.
|
protected |
The unique id of the game that the request is related to
|
protected |
The id of the player that sent the request
|
protected |
The unique id of the request
|
static |
Maps the RequestType enum to the string representation of the RequestType. For serialization.
|
static |
Maps the string representation of the RequestType to the RequestType enum. For deserialization.
|
protected |
The type of the request