2022-02-06 16:48:52 +01:00
|
|
|
//===========================================================================//
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
//===========================================================================//
|
|
|
|
#pragma once
|
2022-02-13 15:10:38 +01:00
|
|
|
#include "protoc/cl_rcon.pb.h"
|
|
|
|
#include "protoc/sv_rcon.pb.h"
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2022-02-08 16:32:00 +01:00
|
|
|
constexpr const char* NETCON_VERSION = "2.0.0.1";
|
|
|
|
|
2022-02-06 16:48:52 +01:00
|
|
|
class CNetCon
|
|
|
|
{
|
|
|
|
public:
|
2022-08-02 23:58:43 +02:00
|
|
|
CNetCon(void);
|
|
|
|
~CNetCon(void);
|
2022-05-28 23:05:10 +02:00
|
|
|
|
2022-02-06 16:48:52 +01:00
|
|
|
bool Init(void);
|
|
|
|
bool Shutdown(void);
|
|
|
|
|
2022-02-08 16:32:00 +01:00
|
|
|
void TermSetup(void);
|
|
|
|
void UserInput(void);
|
|
|
|
|
|
|
|
void RunFrame(void);
|
2022-02-13 15:10:38 +01:00
|
|
|
bool ShouldQuit(void) const;
|
2022-02-08 16:32:00 +01:00
|
|
|
|
2022-02-13 15:10:38 +01:00
|
|
|
bool Connect(const std::string& svInAdr, const std::string& svInPort);
|
|
|
|
void Disconnect(void);
|
|
|
|
|
|
|
|
void Send(const std::string& svMessage) const;
|
2022-02-06 16:48:52 +01:00
|
|
|
void Recv(void);
|
|
|
|
|
2022-08-02 23:58:43 +02:00
|
|
|
void ProcessBuffer(const char* pRecvBuf, int nRecvLen, CConnectedNetConsoleData* pData);
|
2022-02-13 15:10:38 +01:00
|
|
|
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;
|
2022-02-13 15:16:09 +01:00
|
|
|
sv_rcon::response Deserialize(const std::string& svBuf) const;
|
2022-02-13 15:10:38 +01:00
|
|
|
|
2022-02-09 21:29:34 +01:00
|
|
|
private:
|
2022-08-02 23:58:43 +02:00
|
|
|
CNetAdr2* m_pNetAdr2;
|
|
|
|
CSocketCreator* m_pSocket;
|
|
|
|
|
|
|
|
bool m_bInitialized;
|
|
|
|
bool m_bNoColor;
|
|
|
|
bool m_bQuitApplication;
|
|
|
|
std::atomic<bool> m_abPromptConnect;
|
|
|
|
std::atomic<bool> m_abConnEstablished;
|
2022-08-27 18:57:56 +02:00
|
|
|
|
|
|
|
mutable std::mutex m_Mutex;
|
2022-02-06 16:48:52 +01:00
|
|
|
};
|