|
Eile Mit Weile
|
Derivative of ServerResponse that is sent as a response to a ClientRequest. More...
#include <RequestResponse.hpp>
Public Member Functions | |
| RequestResponse (const std::string &game_id, std::string req_id, bool success, rapidjson::Value *state_json, std::string err) | |
| ~RequestResponse () | |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
Public Member Functions inherited from ServerResponse | |
| ResponseType | GetType () const |
| std::string | GetGameId () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
| virtual void | Process () const |
Public Member Functions inherited from Serializable | |
| virtual rapidjson::Document * | ToJson () const |
Static Public Member Functions | |
| static RequestResponse * | FromJson (const rapidjson::Value &json) |
Static Public Member Functions inherited from ServerResponse | |
| static ServerResponse * | FromJson (const rapidjson::Value &json) |
Private Member Functions | |
| RequestResponse (const BaseClassProperties &props, std::string req_id, bool success, rapidjson::Value *state_json, std::string &err) | |
Private Attributes | |
| bool | _success |
| std::string | _err |
| std::string | _req_id |
| rapidjson::Value * | _state_json = nullptr |
Additional Inherited Members | |
Protected Member Functions inherited from ServerResponse | |
| ServerResponse (const BaseClassProperties &) | |
Static Protected Member Functions inherited from ServerResponse | |
| static BaseClassProperties | CreateBaseClassProperties (ResponseType type, const std::string &game_id) |
| static BaseClassProperties | ExtractBaseClassProperties (const rapidjson::Value &json) |
Protected Attributes inherited from ServerResponse | |
| std::string | _game_id |
| ResponseType | _type |
Derivative of ServerResponse that is sent as a response to a ClientRequest.
Note: This class design is taken from https://gitlab.ethz.ch/hraymond/cse-lama-example-project. RequestResponse is a derivative of ServerResponse. Due to static allocation, ServerResponse can call RequestResponse's FromJson method. We think this is very bad design, but changing it would require a lot of refactoring so we decided to leave it as it is. Furthermore, **Process is only declared/defined for the client executable**. This means that this class definition differs between the client and the server executable. Again, we think this is bad design, but we decided to leave it as it is as trying to change it would require a lot of refactoring.
|
private |
Creates a RequestResponse defining all member vars with args using BaseClassProperties
| RequestResponse::RequestResponse | ( | const std::string & | game_id, |
| std::string | req_id, | ||
| bool | success, | ||
| rapidjson::Value * | state_json, | ||
| std::string | err | ||
| ) |
Creates a RequestResponse defining all member vars with args but wihtout using BaseClassProperties
| RequestResponse::~RequestResponse | ( | ) |
Deletes dynamically allocated _state_json (if it exists).
|
static |
Deserializes a RequestResponse from the given json.
|
overridevirtual |
Serializes this RequestResponse into the given json.
Implements Serializable.
|
private |
Error message if the request was not successful.
|
private |
The id of the request this ServerResponse is a response to.
|
private |
The state of the game as a serialized json value.
|
private |
Whether the request was successful.