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.

91 lines
3.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef INETCHANNEL_H
  7. #define INETCHANNEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/platform.h"
  12. #include "inetchannelinfo.h"
  13. #include "tier1/bitbuf.h"
  14. class IDemoRecorder;
  15. class INetMessage;
  16. class INetChannelHandler;
  17. class INetChannelInfo;
  18. typedef struct netpacket_s netpacket_t;
  19. typedef struct netadr_s netadr_t;
  20. abstract_class INetChannel : public INetChannelInfo
  21. {
  22. public:
  23. virtual ~INetChannel( void ) {};
  24. virtual void SetDataRate(float rate) = 0;
  25. virtual bool RegisterMessage(INetMessage *msg) = 0;
  26. virtual bool StartStreaming( unsigned int challengeNr ) = 0;
  27. virtual void ResetStreaming( void ) = 0;
  28. virtual void SetTimeout(float seconds) = 0;
  29. virtual void SetDemoRecorder(IDemoRecorder *recorder) = 0;
  30. virtual void SetChallengeNr(unsigned int chnr) = 0;
  31. virtual void Reset( void ) = 0;
  32. virtual void Clear( void ) = 0;
  33. virtual void Shutdown(const char *reason) = 0;
  34. virtual void ProcessPlayback( void ) = 0;
  35. virtual bool ProcessStream( void ) = 0;
  36. virtual void ProcessPacket( struct netpacket_s* packet, bool bHasHeader ) = 0;
  37. virtual bool SendNetMsg(INetMessage &msg, bool bForceReliable = false, bool bVoice = false ) = 0;
  38. #ifdef POSIX
  39. FORCEINLINE bool SendNetMsg(INetMessage const &msg, bool bForceReliable = false, bool bVoice = false ) { return SendNetMsg( *( (INetMessage *) &msg ), bForceReliable, bVoice ); }
  40. #endif
  41. virtual bool SendData(bf_write &msg, bool bReliable = true) = 0;
  42. virtual bool SendFile(const char *filename, unsigned int transferID) = 0;
  43. virtual void DenyFile(const char *filename, unsigned int transferID) = 0;
  44. virtual void RequestFile_OLD(const char *filename, unsigned int transferID) = 0; // get rid of this function when we version the
  45. virtual void SetChoked( void ) = 0;
  46. virtual int SendDatagram(bf_write *data) = 0;
  47. virtual bool Transmit(bool onlyReliable = false) = 0;
  48. virtual const netadr_t &GetRemoteAddress( void ) const = 0;
  49. virtual INetChannelHandler *GetMsgHandler( void ) const = 0;
  50. virtual int GetDropNumber( void ) const = 0;
  51. virtual int GetSocket( void ) const = 0;
  52. virtual unsigned int GetChallengeNr( void ) const = 0;
  53. virtual void GetSequenceData( int &nOutSequenceNr, int &nInSequenceNr, int &nOutSequenceNrAck ) = 0;
  54. virtual void SetSequenceData( int nOutSequenceNr, int nInSequenceNr, int nOutSequenceNrAck ) = 0;
  55. virtual void UpdateMessageStats( int msggroup, int bits) = 0;
  56. virtual bool CanPacket( void ) const = 0;
  57. virtual bool IsOverflowed( void ) const = 0;
  58. virtual bool IsTimedOut( void ) const = 0;
  59. virtual bool HasPendingReliableData( void ) = 0;
  60. virtual void SetFileTransmissionMode(bool bBackgroundMode) = 0;
  61. virtual void SetCompressionMode( bool bUseCompression ) = 0;
  62. virtual unsigned int RequestFile(const char *filename) = 0;
  63. virtual float GetTimeSinceLastReceived( void ) const = 0; // get time since last received packet in seconds
  64. virtual void SetMaxBufferSize(bool bReliable, int nBytes, bool bVoice = false ) = 0;
  65. virtual bool IsNull() const = 0;
  66. virtual int GetNumBitsWritten( bool bReliable ) = 0;
  67. virtual void SetInterpolationAmount( float flInterpolationAmount ) = 0;
  68. virtual void SetRemoteFramerate( float flFrameTime, float flFrameTimeStdDeviation ) = 0;
  69. // Max # of payload bytes before we must split/fragment the packet
  70. virtual void SetMaxRoutablePayloadSize( int nSplitSize ) = 0;
  71. virtual int GetMaxRoutablePayloadSize() = 0;
  72. virtual int GetProtocolVersion() = 0;
  73. };
  74. #endif // INETCHANNEL_H