mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* Used 'htonl'/'ntohl' for constructing the length prefix. * Used static socket/address members instead of pointers. * Used const qualifier where possible. * Changed length prefix field type to 'u_long'. * Removed extraneous include. * Properly escaped percentage characters on the RCON game client for the ImGui console.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
//===========================================================================//
|
|
//
|
|
// Purpose:
|
|
//
|
|
//===========================================================================//
|
|
#pragma once
|
|
#include "protoc/cl_rcon.pb.h"
|
|
#include "protoc/sv_rcon.pb.h"
|
|
|
|
constexpr const char* NETCON_VERSION = "2.0.0.1";
|
|
|
|
class CNetCon
|
|
{
|
|
public:
|
|
CNetCon(void);
|
|
~CNetCon(void);
|
|
|
|
bool Init(void);
|
|
bool Shutdown(void);
|
|
|
|
void TermSetup(void);
|
|
void UserInput(void);
|
|
|
|
void RunFrame(void);
|
|
bool ShouldQuit(void) const;
|
|
|
|
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* pRecvBuf, int nRecvLen, CConnectedNetConsoleData* pData);
|
|
void ProcessMessage(const sv_rcon::response& sv_response) const;
|
|
|
|
std::string Serialize(const std::string& svReqBuf, const std::string& svReqVal, const cl_rcon::request_t request_t) const;
|
|
sv_rcon::response Deserialize(const std::string& svBuf) const;
|
|
|
|
private:
|
|
bool m_bInitialized;
|
|
bool m_bNoColor;
|
|
bool m_bQuitApplication;
|
|
std::atomic<bool> m_abPromptConnect;
|
|
std::atomic<bool> m_abConnEstablished;
|
|
|
|
CNetAdr2 m_NetAdr2;
|
|
CSocketCreator m_Socket;
|
|
|
|
mutable std::mutex m_Mutex;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// singleton
|
|
//-----------------------------------------------------------------------------
|
|
extern CNetCon* NetConsole(); |