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.

48 lines
1.2 KiB

  1. //====== Copyright (c), Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Holds the CNetPacket class
  4. //
  5. //=============================================================================
  6. #ifndef GCNETPACKET_H
  7. #define GCNETPACKET_H
  8. namespace GCSDK
  9. {
  10. //-----------------------------------------------------------------------------
  11. // Purpose: reference-counted received network packet
  12. //-----------------------------------------------------------------------------
  13. class CNetPacket
  14. {
  15. public:
  16. CNetPacket();
  17. ~CNetPacket();
  18. //called to allocate a buffer for the net packet of the specified size. This takes an optional pointer
  19. //of which it will copy into the data if appropriate
  20. void Init( uint32 cubData, const void* pCopyData = NULL );
  21. //called when working with a net packet that you want to reference a separate buffer
  22. void InitAdoptBuffer( uint32 cubData, uint8* pubData );
  23. void OrphanBuffer();
  24. // data
  25. uint8 *PubData() const { return m_pubData; }
  26. uint CubData() const { return m_cubData; }
  27. // ownership
  28. void AddRef();
  29. void Release();
  30. private:
  31. int m_cRef; // reference count, deletes self when 0
  32. uint m_cubData;
  33. uint8 *m_pubData;
  34. };
  35. } // namespace GCSDK
  36. #endif // GCNETPACKET_H