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.

47 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: INetMessage interface
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef INETMESSAGE_H
  8. #define INETMESSAGE_H
  9. #include "tier1/bitbuf.h"
  10. class INetMsgHandler;
  11. class INetMessage;
  12. class INetChannel;
  13. // typedef bool (INetMsgHandler::*PROCESSFUNCPTR)(INetMessage*);
  14. // #define CASTPROCPTR( fn ) static_cast <bool (INetMsgHandler::*)(INetMessage*)> (fn)
  15. class INetMessage
  16. {
  17. public:
  18. virtual ~INetMessage() {};
  19. // Use these to setup who can hear whose voice.
  20. // Pass in client indices (which are their ent indices - 1).
  21. virtual void SetNetChannel(INetChannel * netchan) = 0; // netchannel this message is from/for
  22. virtual void SetReliable( bool state ) = 0; // set to true if it's a reliable message
  23. virtual bool Process( void ) = 0; // calles the recently set handler to process this message
  24. virtual bool ReadFromBuffer( bf_read &buffer ) = 0; // returns true if parsing was OK
  25. virtual bool WriteToBuffer( bf_write &buffer ) = 0; // returns true if writing was OK
  26. virtual bool IsReliable( void ) const = 0; // true, if message needs reliable handling
  27. virtual int GetType( void ) const = 0; // returns module specific header tag eg svc_serverinfo
  28. virtual int GetGroup( void ) const = 0; // returns net message group of this message
  29. virtual const char *GetName( void ) const = 0; // returns network message name, eg "svc_serverinfo"
  30. virtual INetChannel *GetNetChannel( void ) const = 0;
  31. virtual const char *ToString( void ) const = 0; // returns a human readable string about message content
  32. };
  33. #endif