BF2MC-Matchmaker
gamestats/client.h
1 #ifndef GAMESTATS_CLIENT_H
2 #define GAMESTATS_CLIENT_H
3 
4 #include <net/socket.h>
5 #include <gamespy.h>
6 
7 namespace GameStats
8 {
15  class Client : public Net::Socket
16  {
17  public:
24  Client(int socket, struct sockaddr_in address);
25 
29  ~Client();
30 
37  void Listen();
38 
45  void Disconnect();
46 
47  /*
48  Events
49  */
57  void onRequest(const std::string& request);
58 
59  /*
60  Requests
61  */
68  void requestChallenge();
69 
78  void requestAuth(const GameSpy::Parameter& parameter);
79 
88  void requestNewGame(const GameSpy::Parameter& parameter);
89 
98  void requestUpdateGame(const GameSpy::Parameter& parameter);
99 
100  private:
110  void _LogTransaction(const std::string& direction, const std::string& response) const;
111 
120  bool _GetKeyAndPlayerIndex(const std::string& input, std::string& key, int& player_index);
121 
122  public:
129  static void Heartbeat();
130 
140  static std::vector<unsigned char> Encrypt(const std::string& response);
141 
151  static std::string Decrypt(const std::vector<unsigned char>& request);
152 
153  static void Test();
154  };
155 }
156 
157 #endif // GAMESTATS_CLIENT_H
Represents a client for game statistics.
~Client()
Destructor for Game Statistics Client.
void requestUpdateGame(const GameSpy::Parameter &parameter)
Request to update an existing game with provided parameters.
void onRequest(const std::string &request)
Handle incoming requests from the client.
void Listen()
Start listening for client requests.
static std::vector< unsigned char > Encrypt(const std::string &response)
Encrypts a response message.
void Disconnect()
Disconnect the client.
static void Heartbeat()
Heartbeat function to manage client connections.
void requestAuth(const GameSpy::Parameter &parameter)
Request authentication with provided parameters.
void _LogTransaction(const std::string &direction, const std::string &response) const
Log a transaction with direction and response.
void requestNewGame(const GameSpy::Parameter &parameter)
Request to create a new game with provided parameters.
static std::string Decrypt(const std::vector< unsigned char > &request)
Decrypts a request message.
void requestChallenge()
Request a challenge from the client.
Client(int socket, struct sockaddr_in address)
Constructor for Game Statistics Client.
bool _GetKeyAndPlayerIndex(const std::string &input, std::string &key, int &player_index)
Get the key and the player index from string input.
A base class representing a network socket.
Definition: socket.h:15