Counter Strike : Global Offensive Source Code
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.

84 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, 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. class INetMessage
  14. {
  15. public:
  16. virtual ~INetMessage() {};
  17. // Use these to setup who can hear whose voice.
  18. // Pass in client indices (which are their ent indices - 1).
  19. virtual void SetNetChannel(INetChannel * netchan) { DebuggerBreak(); return; }
  20. virtual void SetReliable( bool state ) = 0; // set to true if it's a reliable message
  21. virtual bool Process( void ) { DebuggerBreak(); return false; }
  22. virtual bool ReadFromBuffer( bf_read &buffer ) = 0; // returns true if parsing was OK
  23. virtual bool WriteToBuffer( bf_write &buffer ) const = 0; // returns true if writing was OK
  24. virtual bool IsReliable( void ) const = 0; // true, if message needs reliable handling
  25. virtual int GetType( void ) const = 0; // returns module specific header tag eg svc_serverinfo
  26. virtual int GetGroup( void ) const = 0; // returns net message group of this message
  27. virtual const char *GetName( void ) const = 0; // returns network message name, eg "svc_serverinfo"
  28. virtual INetChannel *GetNetChannel( void ) const { DebuggerBreak(); return NULL; }
  29. virtual const char *ToString( void ) const = 0; // returns a human readable string about message content
  30. virtual size_t GetSize() const = 0;
  31. };
  32. class INetMessageBinder
  33. {
  34. public:
  35. virtual ~INetMessageBinder() {};
  36. virtual int GetType( void ) const = 0; // returns module specific header tag eg svc_serverinfo
  37. virtual void SetNetChannel(INetChannel * netchan) = 0; // netchannel this message is from/for
  38. virtual INetMessage *CreateFromBuffer( bf_read &buffer ) = 0;
  39. virtual bool Process( const INetMessage &src ) = 0;
  40. };
  41. class INetChannelHandler
  42. {
  43. public:
  44. virtual ~INetChannelHandler( void ) {};
  45. virtual void ConnectionStart(INetChannel *chan) = 0; // called first time network channel is established
  46. virtual void ConnectionStop( ) = 0; // called first time network channel is established
  47. virtual void ConnectionClosing(const char *reason) = 0; // network channel is being closed by remote site
  48. virtual void ConnectionCrashed(const char *reason) = 0; // network error occured
  49. virtual void PacketStart(int incoming_sequence, int outgoing_acknowledged) = 0; // called each time a new packet arrived
  50. virtual void PacketEnd( void ) = 0; // all messages has been parsed
  51. virtual void FileRequested(const char *fileName, unsigned int transferID, bool isReplayDemoFile) = 0; // other side request a file for download
  52. virtual void FileReceived(const char *fileName, unsigned int transferID, bool isReplayDemoFile) = 0; // we received a file
  53. virtual void FileDenied(const char *fileName, unsigned int transferID, bool isReplayDemoFile) = 0; // a file request was denied by other side
  54. virtual void FileSent(const char *fileName, unsigned int transferID, bool isReplayDemoFile) = 0; // we sent a file
  55. virtual bool ChangeSplitscreenUser( int nSplitScreenUserSlot ) = 0; // interleaved networking used by SS system is changing the SS player slot that the subsequent messages pertain to
  56. };
  57. #endif