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.

218 lines
6.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #if !defined( INETMSGHANDLER_H )
  14. #define INETMSGHANDLER_H
  15. #ifdef _WIN32
  16. #pragma once
  17. #endif
  18. class INetChannel;
  19. typedef struct netpacket_s netpacket_t;
  20. class INetChannelHandler
  21. {
  22. public:
  23. virtual ~INetChannelHandler( void ) {};
  24. virtual void ConnectionStart(INetChannel *chan) = 0; // called first time network channel is established
  25. virtual void ConnectionClosing(const char *reason) = 0; // network channel is being closed by remote site
  26. virtual void ConnectionCrashed(const char *reason) = 0; // network error occured
  27. virtual void PacketStart(int incoming_sequence, int outgoing_acknowledged) = 0; // called each time a new packet arrived
  28. virtual void PacketEnd( void ) = 0; // all messages has been parsed
  29. virtual void FileRequested(const char *fileName, unsigned int transferID ) = 0; // other side request a file for download
  30. virtual void FileReceived(const char *fileName, unsigned int transferID ) = 0; // we received a file
  31. virtual void FileDenied(const char *fileName, unsigned int transferID ) = 0; // a file request was denied by other side
  32. virtual void FileSent(const char *fileName, unsigned int transferID ) = 0; // we sent a file
  33. };
  34. #define PROCESS_NET_MESSAGE( name ) \
  35. virtual bool Process##name( NET_##name *msg )
  36. #define PROCESS_SVC_MESSAGE( name ) \
  37. virtual bool Process##name( SVC_##name *msg )
  38. #define PROCESS_CLC_MESSAGE( name ) \
  39. virtual bool Process##name( CLC_##name *msg )
  40. #define PROCESS_MM_MESSAGE( name ) \
  41. virtual bool Process##name( MM_##name *msg )
  42. #define REGISTER_NET_MSG( name ) \
  43. NET_##name * p##name = new NET_##name(); \
  44. p##name->m_pMessageHandler = this; \
  45. chan->RegisterMessage( p##name ); \
  46. #define REGISTER_SVC_MSG( name ) \
  47. SVC_##name * p##name = new SVC_##name(); \
  48. p##name->m_pMessageHandler = this; \
  49. chan->RegisterMessage( p##name ); \
  50. #define REGISTER_CLC_MSG( name ) \
  51. CLC_##name * p##name = new CLC_##name(); \
  52. p##name->m_pMessageHandler = this; \
  53. chan->RegisterMessage( p##name ); \
  54. #define REGISTER_MM_MSG( name ) \
  55. MM_##name * p##name = new MM_##name(); \
  56. p##name->m_pMessageHandler = this; \
  57. chan->RegisterMessage( p##name ); \
  58. class NET_Tick;
  59. class NET_StringCmd;
  60. class NET_SetConVar;
  61. class NET_SignonState;
  62. class INetMessageHandler
  63. {
  64. public:
  65. virtual ~INetMessageHandler( void ) {};
  66. PROCESS_NET_MESSAGE( Tick ) = 0;
  67. PROCESS_NET_MESSAGE( StringCmd ) = 0;
  68. PROCESS_NET_MESSAGE( SetConVar ) = 0;
  69. PROCESS_NET_MESSAGE( SignonState ) = 0;
  70. };
  71. class CLC_ClientInfo;
  72. class CLC_Move;
  73. class CLC_VoiceData;
  74. class CLC_BaselineAck;
  75. class CLC_ListenEvents;
  76. class CLC_RespondCvarValue;
  77. class CLC_FileCRCCheck;
  78. class CLC_FileMD5Check;
  79. class CLC_SaveReplay;
  80. class CLC_CmdKeyValues;
  81. class IClientMessageHandler : public INetMessageHandler
  82. {
  83. public:
  84. virtual ~IClientMessageHandler( void ) {};
  85. PROCESS_CLC_MESSAGE( ClientInfo ) = 0;
  86. PROCESS_CLC_MESSAGE( Move ) = 0;
  87. PROCESS_CLC_MESSAGE( VoiceData ) = 0;
  88. PROCESS_CLC_MESSAGE( BaselineAck ) = 0;
  89. PROCESS_CLC_MESSAGE( ListenEvents ) = 0;
  90. PROCESS_CLC_MESSAGE( RespondCvarValue ) = 0;
  91. PROCESS_CLC_MESSAGE( FileCRCCheck ) = 0;
  92. PROCESS_CLC_MESSAGE( FileMD5Check ) = 0;
  93. #if defined( REPLAY_ENABLED )
  94. PROCESS_CLC_MESSAGE( SaveReplay ) = 0;
  95. #endif
  96. PROCESS_CLC_MESSAGE( CmdKeyValues ) = 0;
  97. };
  98. class SVC_Print;
  99. class SVC_ServerInfo;
  100. class SVC_SendTable;
  101. class SVC_ClassInfo;
  102. class SVC_SetPause;
  103. class SVC_CreateStringTable;
  104. class SVC_UpdateStringTable;
  105. class SVC_VoiceInit;
  106. class SVC_VoiceData;
  107. class SVC_Sounds;
  108. class SVC_SetView;
  109. class SVC_FixAngle;
  110. class SVC_CrosshairAngle;
  111. class SVC_BSPDecal;
  112. class SVC_GameEvent;
  113. class SVC_UserMessage;
  114. class SVC_EntityMessage;
  115. class SVC_PacketEntities;
  116. class SVC_TempEntities;
  117. class SVC_Prefetch;
  118. class SVC_Menu;
  119. class SVC_GameEventList;
  120. class SVC_GetCvarValue;
  121. class SVC_CmdKeyValues;
  122. class SVC_SetPauseTimed;
  123. class IServerMessageHandler : public INetMessageHandler
  124. {
  125. public:
  126. virtual ~IServerMessageHandler( void ) {};
  127. // Returns dem file protocol version, or, if not playing a demo, just returns PROTOCOL_VERSION
  128. virtual int GetDemoProtocolVersion() const = 0;
  129. PROCESS_SVC_MESSAGE( Print ) = 0;
  130. PROCESS_SVC_MESSAGE( ServerInfo ) = 0;
  131. PROCESS_SVC_MESSAGE( SendTable ) = 0;
  132. PROCESS_SVC_MESSAGE( ClassInfo ) = 0;
  133. PROCESS_SVC_MESSAGE( SetPause ) = 0;
  134. PROCESS_SVC_MESSAGE( CreateStringTable ) = 0;
  135. PROCESS_SVC_MESSAGE( UpdateStringTable ) = 0;
  136. PROCESS_SVC_MESSAGE( VoiceInit ) = 0;
  137. PROCESS_SVC_MESSAGE( VoiceData ) = 0;
  138. PROCESS_SVC_MESSAGE( Sounds ) = 0;
  139. PROCESS_SVC_MESSAGE( SetView ) = 0;
  140. PROCESS_SVC_MESSAGE( FixAngle ) = 0;
  141. PROCESS_SVC_MESSAGE( CrosshairAngle ) = 0;
  142. PROCESS_SVC_MESSAGE( BSPDecal ) = 0;
  143. PROCESS_SVC_MESSAGE( GameEvent ) = 0;
  144. PROCESS_SVC_MESSAGE( UserMessage ) = 0;
  145. PROCESS_SVC_MESSAGE( EntityMessage ) = 0;
  146. PROCESS_SVC_MESSAGE( PacketEntities ) = 0;
  147. PROCESS_SVC_MESSAGE( TempEntities ) = 0;
  148. PROCESS_SVC_MESSAGE( Prefetch ) = 0;
  149. PROCESS_SVC_MESSAGE( Menu ) = 0;
  150. PROCESS_SVC_MESSAGE( GameEventList ) = 0;
  151. PROCESS_SVC_MESSAGE( GetCvarValue ) = 0;
  152. PROCESS_SVC_MESSAGE( CmdKeyValues ) = 0;
  153. PROCESS_SVC_MESSAGE( SetPauseTimed ) = 0;
  154. };
  155. class MM_Heartbeat;
  156. class MM_ClientInfo;
  157. class MM_JoinResponse;
  158. class MM_RegisterResponse;
  159. class MM_Migrate;
  160. class MM_Mutelist;
  161. class MM_Checkpoint;
  162. class IMatchmakingMessageHandler : public INetMessageHandler
  163. {
  164. public:
  165. virtual ~IMatchmakingMessageHandler( void ) {};
  166. PROCESS_MM_MESSAGE( Heartbeat ) = 0;
  167. PROCESS_MM_MESSAGE( ClientInfo ) = 0;
  168. PROCESS_MM_MESSAGE( JoinResponse ) = 0;
  169. PROCESS_MM_MESSAGE( RegisterResponse ) = 0;
  170. PROCESS_MM_MESSAGE( Migrate ) = 0;
  171. PROCESS_MM_MESSAGE( Mutelist ) = 0;
  172. PROCESS_MM_MESSAGE( Checkpoint) = 0;
  173. };
  174. class IConnectionlessPacketHandler
  175. {
  176. public:
  177. virtual ~IConnectionlessPacketHandler( void ) {};
  178. virtual bool ProcessConnectionlessPacket( netpacket_t *packet ) = 0; // process a connectionless packet
  179. };
  180. #endif // INETMSGHANDLER_H