diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/gcsdk/netpacket.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/gcsdk/netpacket.h')
| -rw-r--r-- | public/gcsdk/netpacket.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/public/gcsdk/netpacket.h b/public/gcsdk/netpacket.h new file mode 100644 index 0000000..f3ba033 --- /dev/null +++ b/public/gcsdk/netpacket.h @@ -0,0 +1,48 @@ +//====== Copyright (c), Valve Corporation, All rights reserved. ======= +// +// Purpose: Holds the CNetPacket class +// +//============================================================================= + +#ifndef GCNETPACKET_H +#define GCNETPACKET_H + +namespace GCSDK +{ + +//----------------------------------------------------------------------------- +// Purpose: reference-counted received network packet +//----------------------------------------------------------------------------- +class CNetPacket +{ +public: + CNetPacket(); + ~CNetPacket(); + + //called to allocate a buffer for the net packet of the specified size. This takes an optional pointer + //of which it will copy into the data if appropriate + void Init( uint32 cubData, const void* pCopyData = NULL ); + + //called when working with a net packet that you want to reference a separate buffer + void InitAdoptBuffer( uint32 cubData, uint8* pubData ); + void OrphanBuffer(); + + // data + uint8 *PubData() const { return m_pubData; } + uint CubData() const { return m_cubData; } + + // ownership + void AddRef(); + void Release(); + +private: + int m_cRef; // reference count, deletes self when 0 + uint m_cubData; + uint8 *m_pubData; +}; + + + +} // namespace GCSDK + +#endif // GCNETPACKET_H |