Network/NetPacket: Add Get(Const)Data method

Former-commit-id: 53f4f230b3e7baa65c79d97b21e192108b771312
This commit is contained in:
Lynix 2016-02-04 13:24:08 +01:00
parent 4e3244c999
commit 33e2bb905b
2 changed files with 18 additions and 1 deletions

View File

@ -28,6 +28,8 @@ namespace Nz
NetPacket(NetPacket&&) = default;
inline ~NetPacket();
inline const UInt8* GetConstData() const;
inline UInt8* GetData() const;
inline UInt16 GetNetCode() const;
virtual void OnReceive(UInt16 netCode, const void* data, std::size_t size);

View File

@ -2,9 +2,10 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Debug.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Network/Enums.hpp>
#include <cstring>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
@ -28,6 +29,20 @@ namespace Nz
FreeStream();
}
inline const UInt8* NetPacket::GetConstData() const
{
NazaraAssert(m_buffer, "Invalid buffer");
return m_buffer->GetConstBuffer();
}
inline UInt8* NetPacket::GetData() const
{
NazaraAssert(m_buffer, "Invalid buffer");
return m_buffer->GetBuffer();
}
inline UInt16 NetPacket::GetNetCode() const
{
return m_netCode;