Mania++
 All Classes Functions Variables Pages
GbxRemote.h
1 #ifndef GBXREMOTE_H_
2 #define GBXREMOTE_H_
3 
4 #include "../Socket/TcpClient.h"
5 #include <sstream>
6 #include <vector>
7 
8 #include "GbxStructs.h"
9 #include "Message/GbxMessage.h"
10 #include "Parameters/GbxParameters.h"
11 #include "Response/GbxResponse.h"
12 #include "CallBack/GbxCallBack.h"
13 
14 //* GbxRemote
20 class GbxRemote
21 {
22 public:
26  ~GbxRemote();
27 
33  bool Init(int port);
34 
41  bool InitWithIp(std::string address, int port);
42 
46  void Terminate();
47 
55  bool Query(GbxMessage query);
56 
62  bool ReadCallBacks();
63 
69  void HandleCallBack(std::string data);
70 
74  std::vector<GbxCallBack> GetCBResponses();
75 
79  void ResetCBResponses();
80 
85 
92 
96  int GetProtocol();
97 
101  std::string GetApiVersion();
102 
103 private:
104  bool connected = false;
106  int protocol = 0;
107  std::string apiVersion;
112  std::vector<GbxCallBack> currentCallBacks = std::vector<GbxCallBack>();
113 };
114 
115 #endif // GBXREMOTE_H_
int GetProtocol()
Returns the current version number of the server protocol (1 or 2).
Definition: GbxRemote.cpp:198
bool Query(GbxMessage query)
Sends a GbxMessage to the server.
Definition: GbxRemote.cpp:72
std::string GetApiVersion()
Returns the set API version.
Definition: GbxRemote.cpp:203
Handles communication with the ManiaPlanet server.
Definition: GbxRemote.h:20
bool connected
Is the client connected with the server?
Definition: GbxRemote.h:104
GbxError currentError
Current server error.
Definition: GbxRemote.h:110
bool ReadCallBacks()
Read callbacks from the server.
Definition: GbxRemote.cpp:132
Response from server, de-XML-fies the response.
Definition: GbxResponse.h:10
XML-fies the message for communication with the server.
Definition: GbxMessage.h:14
Socket connection with server.
Definition: TcpClient.h:25
GbxError GetCurrentError()
Returns the current server error.
Definition: GbxRemote.cpp:183
void Terminate()
Closes the connection with the server.
Definition: GbxRemote.cpp:65
void ResetCBResponses()
Resets list of current callbacks.
Definition: GbxRemote.cpp:178
GbxResponse * currentResponse
Current server response.
Definition: GbxRemote.h:111
bool Init(int port)
Initializes connection with the local server.
Definition: GbxRemote.cpp:11
void HandleCallBack(std::string data)
Handles callbacks (de-XML-fies them).
Definition: GbxRemote.cpp:166
~GbxRemote()
Definition: GbxRemote.cpp:3
bool InitWithIp(std::string address, int port)
Initializes connection with the server.
Definition: GbxRemote.cpp:16
std::vector< GbxCallBack > GetCBResponses()
Returns the callbacks that have been received since last call.
Definition: GbxRemote.cpp:173
GbxResponse * GetResponse()
Returns the response from the server.
Definition: GbxRemote.cpp:188
Stores error details from the communication with the server.
Definition: GbxStructs.h:27
std::vector< GbxCallBack > currentCallBacks
List of currently received callbacks.
Definition: GbxRemote.h:112
std::string apiVersion
Server API version.
Definition: GbxRemote.h:107
int protocol
Protocol version (0 = uninitialized, 1 or 2 = version).
Definition: GbxRemote.h:106
TcpClient server
Socket connection with the server.
Definition: GbxRemote.h:108