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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#ifndef CL_RCON_H
#define CL_RCON_H
#ifdef _WIN32
#pragma once
#endif
#include "sv_main.h"
#include "netmessages.h"
#include "net.h"
#include "client.h"
#include "utlvector.h"
#include "utllinkedlist.h"
#include "netadr.h"
#include "sv_remoteaccess.h"
#include "sv_rcon.h"
#include "socketcreator.h"
#include "igameserverdata.h"
#include "ivprofexport.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
abstract_class IVProfData
{
public:
virtual void OnRemoteGroupData( const void *data, int len ) = 0;
virtual void OnRemoteData( const void *data, int len ) = 0;
};
//-----------------------------------------------------------------------------
// Used to display client perf data in showbudget
//-----------------------------------------------------------------------------
class CRConVProfExport : public IVProfExport, public IVProfData
{
// Inherited from IVProfExport
public:
virtual void AddListener();
virtual void RemoveListener();
virtual void PauseProfile();
virtual void ResumeProfile();
virtual void SetBudgetFlagsFilter( int filter );
virtual int GetNumBudgetGroups();
virtual void GetBudgetGroupInfos( CExportedBudgetGroupInfo *pInfos );
virtual void GetBudgetGroupTimes( float times[MAX_BUDGETGROUP_TIMES] );
// Inherited from IVProfData
public:
virtual void OnRemoteGroupData( const void *data, int len );
virtual void OnRemoteData( const void *data, int len );
// Other public methods
public:
CRConVProfExport();
private:
void CleanupGroupData();
CUtlVector< CExportedBudgetGroupInfo > m_Info;
CUtlVector<float> m_Times; // Times from the most recent snapshot.
};
class CRConClient : public ISocketCreatorListener
{
public:
CRConClient();
~CRConClient();
void SetAddress( const netadr_t & netAdr );
// Connects to the address specified by SetAddress
bool ConnectSocket();
void Disconnect() { CloseSocket(); }
// Creates a listen server, connects to remote machines that connect to it
void CreateListenSocket( const netadr_t &netAdr );
void CloseListenSocket();
void RunFrame();
void SendCmd( const char *msg );
bool IsConnected() const;
bool IsAuthenticated() const { return m_bAuthenticated; }
void RegisterVProfDataCallback( IVProfData *callback );
void StopVProfData();
void StartVProfData();
void TakeScreenshot();
void GrabConsoleLog();
void SetPassword( const char *pPassword );
void SetRemoteFileDirectory( const char *pDir );
// Inherited from ISocketCreatorListener
virtual bool ShouldAcceptSocket( SocketHandle_t hSocket, const netadr_t & netAdr );
virtual void OnSocketAccepted( SocketHandle_t hSocket, const netadr_t & netAdr, void** ppData );
virtual void OnSocketClosed( SocketHandle_t hSocket, const netadr_t & netAdr, void* pData );
private:
SocketHandle_t GetSocketHandle() const;
void CloseSocket();
void Authenticate();
void ParseReceivedData();
void SendQueuedData();
void SendResponse( CUtlBuffer &response, bool bAutoAuthenticate = true );
void BuildResponse( CUtlBuffer &response, ServerDataRequestType_t msg, const char *pString1, const char *pString2 );
void SaveRemoteScreenshot( const void* pBuffer, int nBufLen );
void SaveRemoteConsoleLog( const void* pBuffer, int nBufLen );
CRConVProfExport m_VProfExport;
CSocketCreator m_Socket;
netadr_t m_Address;
int m_iAuthRequestID;
int m_iReqID;
bool m_bAuthenticated;
CUtlBuffer m_RecvBuffer;
CUtlBuffer m_SendBuffer;
CUtlString m_Password;
CUtlString m_RemoteFileDir;
int m_nScreenShotIndex;
int m_nConsoleLogIndex;
};
inline SocketHandle_t CRConClient::GetSocketHandle() const
{
return m_Socket.GetAcceptedSocketHandle( 0 );
}
CRConClient & RCONClient();
#ifdef ENABLE_RPT
CRConClient & RPTClient(); // used in remote perf testing
#endif // ENABLE_RPT
#endif // CL_RCON_H
|