From cf2fefaaa95cfbb183ed10f504af6a8ef6c5f16a Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 15 Oct 2015 16:12:57 -0400 Subject: [PATCH] Update INetChannel. --- public/inetchannel.h | 108 +++++++++++++++++++++------------------ public/inetchannelinfo.h | 6 +-- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/public/inetchannel.h b/public/inetchannel.h index ab2125b0..8463b82f 100644 --- a/public/inetchannel.h +++ b/public/inetchannel.h @@ -14,18 +14,27 @@ #include "inetchannelinfo.h" #include "tier1/bitbuf.h" #include "tier1/netadr.h" +#include -class IDemoRecorder; +class IDemoRecorderBase; +class IInstantReplayIntercept; class IInstantReplayIntercept; class INetMessage; class INetChannelHandler; class INetChannelInfo; class INetMessageBinder; -typedef struct netpacket_s netpacket_t; +class INetworkMessageProcessingPreFilter; +class INetMessageDispatcher; +class InstantReplayMessage_t; +class CUtlSlot; + +DECLARE_HANDLE_32BIT(CSplitScreenPlayerSlot); +DECLARE_POINTER_HANDLE(NetMessageHandle_t); + #ifndef NET_PACKET_ST_DEFINED #define NET_PACKET_ST_DEFINED -typedef struct netpacket_s +struct NetPacket_t { netadr_t from; // sender IP int source; // received source @@ -35,8 +44,8 @@ typedef struct netpacket_s int size; // size in bytes int wiresize; // size in bytes before decompression bool stream; // was send as stream - struct netpacket_s *pNext; // for internal use, should be NULL in public -} netpacket_t; + struct NetPacket_t *pNext; // for internal use, should be NULL in public +}; #endif // NET_PACKET_ST_DEFINED enum NetChannelBufType_t @@ -51,75 +60,74 @@ abstract_class INetChannel : public INetChannelInfo public: virtual ~INetChannel( void ) {}; - virtual void SetDataRate(float rate) = 0; - virtual bool RegisterMessage(INetMessageBinder *msg) = 0; - virtual bool UnregisterMessage(INetMessageBinder *msg) = 0; + virtual size_t GetTotalPacketBytes( int, int ) const = 0; + virtual size_t GetTotalPacketReliableBytes( int, int ) const = 0; virtual void SetTimeout(float seconds, bool bForceExact = false) = 0; - virtual void SetDemoRecorder(IDemoRecorder *recorder) = 0; - virtual void SetInstantReplayIntercept(IInstantReplayIntercept *intercept) = 0; virtual void Reset( void ) = 0; virtual void Clear( void ) = 0; virtual void Shutdown(/* ENetworkDisconnectionReason */ int reason) = 0; - virtual bool ProcessDemoPacket( struct netpacket_s* packet ) = 0; - virtual bool InsertReplayMessage( INetMessage *msg ) = 0; - virtual void ProcessPacket( struct netpacket_s* packet, bool bHasHeader ) = 0; - - virtual bool SendNetMsg(INetMessage &msg, bool bForceReliable = false, bool bVoice = false ) = 0; -#ifdef POSIX - FORCEINLINE bool SendNetMsg(INetMessage const &msg, bool bForceReliable = false, bool bVoice = false ) { return SendNetMsg( *( (INetMessage *) &msg ), bForceReliable, bVoice ); } -#endif - virtual bool SendData(bf_write &msg, bool bReliable = true) = 0; - virtual bool SendFile(const char *filename, unsigned int transferID, bool isReplayDemo) = 0; - virtual void DenyFile(const char *filename, unsigned int transferID, bool isReplayDemo) = 0; - virtual void RequestFile_OLD(const char *filename, unsigned int transferID) = 0; // get rid of this function when we version the + virtual bool SendData( bf_write &msg, NetChannelBufType_t bufferType ) = 0; virtual void SetChoked( void ) = 0; virtual int SendDatagram(bf_write *data) = 0; virtual bool Transmit(bool onlyReliable = false) = 0; virtual const netadr_t &GetRemoteAddress( void ) const = 0; - virtual INetChannelHandler *GetMsgHandler( void ) const = 0; virtual int GetDropNumber( void ) const = 0; - virtual int GetSocket( void ) const = 0; - virtual unsigned int GetChallengeNr( void ) const = 0; - virtual void GetSequenceData( int &nOutSequenceNr, int &nInSequenceNr, int &nOutSequenceNrAck ) = 0; - virtual void SetSequenceData( int nOutSequenceNr, int nInSequenceNr, int nOutSequenceNrAck ) = 0; - virtual void UpdateMessageStats( int msggroup, int bits) = 0; + virtual void UpdateMessageStats( int msggroup, int bits, bool ) = 0; virtual bool CanPacket( void ) const = 0; virtual bool IsOverflowed( void ) const = 0; - virtual bool IsTimedOut( void ) const = 0; virtual bool HasPendingReliableData( void ) = 0; - virtual void SetFileTransmissionMode(bool bBackgroundMode) = 0; - virtual void SetCompressionMode( bool bUseCompression ) = 0; - virtual unsigned int RequestFile(const char *filename, bool isReplayDemoFile) = 0; - - virtual void SetMaxBufferSize( ENetChannelBufType bufferType, int nBytes ) = 0; - - virtual bool IsNull() const = 0; - virtual void SetInterpolationAmount( float flInterpolationAmount ) = 0; - virtual void SetRemoteFramerate( float flFrameTime, float flFrameTimeStdDeviation, float flFrameStartTimeStdDeviation ) = 0; - - // Max # of payload bytes before we must split/fragment the packet - virtual void SetMaxRoutablePayloadSize( int nSplitSize ) = 0; - virtual int GetMaxRoutablePayloadSize() = 0; + virtual void SetMaxBufferSize( NetChannelBufType_t bufferType, int nBytes ) = 0; // For routing messages to a different handler virtual bool SetActiveChannel( INetChannel *pNewChannel ) = 0; - virtual void AttachSplitPlayer( int nSplitPlayerSlot, INetChannel *pChannel ) = 0; - virtual void DetachSplitPlayer( int nSplitPlayerSlot ) = 0; + virtual void AttachSplitPlayer( CSplitScreenPlayerSlot nSplitPlayerSlot, INetChannel *pChannel ) = 0; + virtual void DetachSplitPlayer( CSplitScreenPlayerSlot nSplitPlayerSlot ) = 0; + virtual void SetUsesMaxRoutablePlayload(bool useMax) = 0; + virtual void SetDataRate(float rate) = 0; + virtual void SetUpdateRate( int rate ) = 0; + virtual void SetCommandRate( int rate ) = 0; + + virtual bool IsTimedOut( void ) const = 0; + + virtual void SetRemoteFramerate( float flFrameTime, float flFrameTimeStdDeviation, float flFrameStartTimeStdDeviation ) = 0; virtual bool IsRemoteDisconnected() const = 0; - virtual int GetNumBitsWritten(ENetChannelBufType bufferType) const = 0; - - virtual void SetUsesMaxRoutablePlayload(bool useMax) = 0; - + virtual void SetNetMessageDispatcher( INetMessageDispatcher *pDispatcher ) = 0; + virtual INetMessageDispatcher *GetNetMessageDispatcher( void ) const = 0; + virtual void SendNetMessage( NetMessageHandle_t msg, const void *pData, NetChannelBufType_t bufType ) = 0; + virtual void StartRegisteringMessageHandlers( void ) = 0; + virtual void FinishRegisteringMessageHandlers( void ) = 0; + virtual void RegisterNetMessageHandlerAbstract( CUtlSlot *, const CUtlAbstractDelegate &, int, NetMessageHandle_t , int ) = 0; + virtual void UnregisterNetMessageHandlerAbstract( CUtlSlot *, const CUtlAbstractDelegate &, NetMessageHandle_t ) = 0; + virtual void SetChallengeNr( unsigned int challenge ) = 0; + virtual void GetSequenceData( int &nOutSequenceNr, int &nInSequenceNr, int &nOutSequenceNrAck ) = 0; + virtual void SetSequenceData( int nOutSequenceNr, int nInSequenceNr, int nOutSequenceNrAck ) = 0; + virtual int GetNumBitsWritten(NetChannelBufType_t bufferType) const = 0; + virtual void SetCompressionMode( bool ) = 0; + // Max # of payload bytes before we must split/fragment the packet + virtual void SetMaxRoutablePayloadSize( int nSplitSize ) = 0; + virtual int GetMaxRoutablePayloadSize() = 0; + virtual void ProcessPacket( bf_read &packet, bool bHasHeader ) = 0; + virtual void SetDemoRecorder( IDemoRecorderBase * ) = 0; + virtual void SetInstantReplayIntercept( IInstantReplayIntercept * ) = 0; + virtual void SetInterpolationAmount( float flInterpolationAmount ) = 0; + virtual void SetFileTransmissionMode( bool ) = 0; + virtual bool IsNull() const = 0; + virtual bool ProcessDemoPacket( NetPacket_t* packet ) = 0; virtual bool WasLastMessageReliable() const = 0; - - virtual void SetPendingDisconnect( int reason ) = 0; + virtual void InstallMessageFilter( INetworkMessageProcessingPreFilter * ) = 0; + virtual void UninstallMessageFilter( INetworkMessageProcessingPreFilter * ) = 0; + virtual void PostReceivedNetMessage(NetMessageHandle_t, const void *, const NetChannelBufType_t* ) = 0; + virtual bool InsertReplayMessage( InstantReplayMessage_t &msg ) = 0; + virtual bool HasQueuedPackets( void ) const = 0; + + virtual void SetPendingDisconnect( /*ENetworkDisconnectReason*/ int reason ) = 0; virtual int GetPendingDisconnect() const = 0; }; diff --git a/public/inetchannelinfo.h b/public/inetchannelinfo.h index 8e8308d0..30722f01 100644 --- a/public/inetchannelinfo.h +++ b/public/inetchannelinfo.h @@ -52,9 +52,10 @@ public: virtual int GetBufferSize( void ) const = 0; // netchannel packet history size virtual int GetDataRate( void ) const = 0; // send data rate in byte/sec + virtual bool IsLocalHost( void ) const = 0; // true if localhost virtual bool IsLoopback( void ) const = 0; // true if loopback channel - virtual bool IsLocalhost( void ) const = 0; // true if localhost virtual bool IsTimingOut( void ) const = 0; // true if timing out + virtual bool IsPlayback( void ) const = 0; virtual float GetLatency( int flow ) const = 0; // current latency (RTT), more accurate but jittering virtual float GetAvgLatency( int flow ) const = 0; // average packet latency in seconds @@ -68,8 +69,7 @@ public: virtual int GetSequenceNr( int flow ) const = 0; // last send seq number virtual bool IsValidPacket( int flow, int frame_number ) const = 0; // true if packet was not lost/dropped/chocked/flushed virtual float GetPacketTime( int flow, int frame_number ) const = 0; // time when packet was send - virtual int GetPacketBytes( int flow, int frame_number, int group ) const = 0; // group size of this packet - virtual bool GetStreamProgress( int flow, int *received, int *total ) const = 0; // TCP progress if transmitting + virtual int GetPacketBits( int flow, int frame_number, int group ) const = 0; // group size of this packet virtual float GetTimeSinceLastReceived( void ) const = 0; // get time since last recieved packet in seconds virtual float GetCommandInterpolationAmount( int flow, int frame_number ) const = 0; virtual void GetPacketResponseLatency( int flow, int frame_number, int *pnLatencyMsecs, int *pnChoke ) const = 0;