2022-08-15 14:44:54 +02:00
|
|
|
|
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======//
|
|
|
|
|
//
|
|
|
|
|
// Purpose: INetMessage interface
|
|
|
|
|
//
|
|
|
|
|
// $NoKeywords: $
|
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
|
|
#ifndef INETMESSAGE_H
|
|
|
|
|
#define INETMESSAGE_H
|
|
|
|
|
|
|
|
|
|
#include "tier1/bitbuf.h"
|
|
|
|
|
|
|
|
|
|
class INetMsgHandler;
|
|
|
|
|
class INetMessage;
|
2023-02-18 00:03:30 +01:00
|
|
|
|
class CNetChan;
|
2022-08-15 14:44:54 +02:00
|
|
|
|
|
|
|
|
|
// typedef bool (INetMsgHandler::*PROCESSFUNCPTR)(INetMessage*);
|
|
|
|
|
// #define CASTPROCPTR( fn ) static_cast <bool (INetMsgHandler::*)(INetMessage*)> (fn)
|
|
|
|
|
|
|
|
|
|
class INetMessage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~INetMessage() {};
|
|
|
|
|
|
|
|
|
|
// Use these to setup who can hear whose voice.
|
|
|
|
|
// Pass in client indices (which are their ent indices - 1).
|
|
|
|
|
|
2023-02-18 00:03:30 +01:00
|
|
|
|
virtual void SetNetChannel(CNetChan* netchan) = 0; // netchannel this message is from/for
|
2022-08-15 14:44:54 +02:00
|
|
|
|
virtual void SetReliable( bool state ) = 0; // set to true if it's a reliable message
|
|
|
|
|
|
2022-09-09 19:47:31 +02:00
|
|
|
|
virtual bool Process( void ) = 0; // calls the recently set handler to process this message
|
2022-08-15 14:44:54 +02:00
|
|
|
|
|
2023-02-18 00:03:30 +01:00
|
|
|
|
virtual bool ReadFromBuffer( bf_read *buffer ) = 0; // returns true if parsing was OK
|
|
|
|
|
virtual bool WriteToBuffer( bf_write *buffer ) = 0; // returns true if writing was OK
|
2022-08-15 14:44:54 +02:00
|
|
|
|
|
|
|
|
|
virtual bool IsReliable( void ) const = 0; // true, if message needs reliable handling
|
|
|
|
|
|
|
|
|
|
virtual int GetGroup( void ) const = 0; // returns net message group of this message
|
|
|
|
|
virtual int GetType( void ) const = 0; // returns module specific header tag eg svc_serverinfo
|
|
|
|
|
virtual const char *GetName( void ) const = 0; // returns network message name, eg "svc_serverinfo"
|
2023-02-18 00:03:30 +01:00
|
|
|
|
virtual CNetChan *GetNetChannel( void ) const = 0;
|
2022-08-15 14:44:54 +02:00
|
|
|
|
virtual const char *ToString( void ) const = 0; // returns a human readable string about message content
|
|
|
|
|
virtual size_t GetSize( void ) const = 0; // returns net message size of this message
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // INETMESSAGE_H
|
|
|
|
|
|