Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Handles all the functions for implementing remote access to the engine
  4. //
  5. //===========================================================================//
  6. #ifndef SV_REMOTEACCESS_H
  7. #define SV_REMOTEACCESS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "igameserverdata.h"
  12. #include "utlbuffer.h"
  13. #include "utllinkedlist.h"
  14. class CRConServer;
  15. class CServerRemoteAccess : public IGameServerData
  16. {
  17. public:
  18. CServerRemoteAccess();
  19. // handles a request
  20. virtual void WriteDataRequest( ra_listener_id listener, const void *buffer, int bufferSize );
  21. void WriteDataRequest( CRConServer *pNetworkListener, ra_listener_id listener, const void *buffer, int bufferSize);
  22. // gets return value from the server
  23. // returns the number of bytes read
  24. virtual int ReadDataResponse( ra_listener_id listener, void *buffer, int bufferSize);
  25. int GetDataResponseSize( ra_listener_id listener );
  26. // sends a message to all the watching admin UI's
  27. void SendMessageToAdminUI( ra_listener_id listenerID, const char *message);
  28. void SendVProfData( ra_listener_id listenerID, bool bGroupData, void *data, int len );
  29. virtual ra_listener_id GetNextListenerID( bool authConnection, const netadr_t *adr = NULL );
  30. virtual void RegisterAdminUIID( ra_listener_id listener ) { m_AdminUIID = listener; }
  31. ra_listener_id GetAdminUIID() { return m_AdminUIID; }
  32. void GetStatsString(char *buf, int bufSize); // also used by the 'stats' command
  33. void UploadScreenshot( const char *pFileName );
  34. private:
  35. void RespondString( ra_listener_id listener, int requestID, const char *pString );
  36. void RequestValue( ra_listener_id listener, int requestID, const char *variable );
  37. void SetValue(const char *variable, const char *value);
  38. void ExecCommand(const char *cmdString);
  39. bool LookupValue(const char *variable, CUtlBuffer &value);
  40. const char *LookupStringValue(const char *variable);
  41. bool IsAuthenticated( ra_listener_id listener );
  42. void CheckPassword( CRConServer *pNetworkListener, ra_listener_id listener, int requestID, const char *password );
  43. void BadPassword( CRConServer *pNetworkListener, ra_listener_id listener );
  44. void LogCommand( ra_listener_id listener, const char *msg );
  45. void SendResponseToClient( ra_listener_id listenerID, ServerDataResponseType_t type, void *pData, int nDataLen );
  46. // specific value requests
  47. void GetUserBanList(CUtlBuffer &value);
  48. void GetPlayerList(CUtlBuffer &value);
  49. void GetMapList(CUtlBuffer &value);
  50. // list of responses waiting to be sent
  51. struct DataResponse_t
  52. {
  53. CUtlBuffer packet;
  54. ra_listener_id responderID;
  55. };
  56. CUtlLinkedList<DataResponse_t, int> m_ResponsePackets;
  57. struct ListenerStore_t
  58. {
  59. ra_listener_id listenerID;
  60. bool authenticated;
  61. bool m_bHasAddress;
  62. netadr_t adr;
  63. };
  64. CUtlLinkedList<ListenerStore_t, int> m_ListenerIDs;
  65. ra_listener_id m_NextListenerID;
  66. int m_nScreenshotListener;
  67. int m_iBytesSent;
  68. int m_iBytesReceived;
  69. ra_listener_id m_AdminUIID;
  70. };
  71. extern CServerRemoteAccess g_ServerRemoteAccess;
  72. extern "C" void NotifyDedicatedServerUI(const char *message);
  73. #endif // SV_REMOTEACCESS_H