aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/cl_rcon.h
blob: ddfd0ed5c6f89795ec4db2db1163c7cc4e3a374a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include "NetAdr2.h"
#include "SocketCreator.h"
#include "sv_rcon.pb.h"
#include "cl_rcon.pb.h"

class CRConClient
{
  public:
	CRConClient(void) {};
	~CRConClient(void) {};

	void Init(void);
	void Shutdown(void);

	void RunFrame(void);

	bool Connect(void);
	bool Connect(const std::string& svInAdr, const std::string& svInPort);
	void Disconnect(void);

	void Send(const std::string& svMessage) const;
	void Recv(void);

	void ProcessBuffer(const char* pszIn, int nRecvLen) const;
	void ProcessMessage(const sv_rcon::response& sv_response) const;

	std::string Serialize(const std::string& svReqBuf, const std::string& svReqVal, cl_rcon::request_t request_t) const;
	sv_rcon::response Deserialize(const std::string& svBuf) const;

	bool IsInitialized(void) const;
	bool IsConnected(void) const;

  private:
	CNetAdr2* m_pNetAdr2 = new CNetAdr2("localhost", "37015");
	CSocketCreator* m_pSocket = new CSocketCreator();

	bool m_bInitialized = false;
	bool m_bConnEstablished = false;
};
extern CRConClient* g_pRConClient;