104 virtual uint32_t
Size()
const = 0;
126 virtual std::shared_ptr<IPacket>
Clone()
const = 0;
a bufferised and thread safe RAII wrapper for a socket representing a connection.
Definition: Connection.hpp:29
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
static const uint32_t STATIC_HEADER_SIZE
Definition: IPacket.hpp:63
uint64_t GetConnectionId() const
Get the Connection Id ( eg source of the packet or destination if it's a response)
Definition: IPacket.hpp:133
Type
Definition: IPacket.hpp:48
virtual bool HasDynamicSize() const =0
Tell if the packet has a dynamic size.
virtual void Deserialize(const uint8_t *buffer)=0
read the packet from the buffer, the buffer must at least be of size Size()
IPacket()
Definition: IPacket.cpp:3
static const uint32_t DYNAMIC_HEADER_SIZE
Definition: IPacket.hpp:64
void ExtractMessage(Connection &connection)
Extracts the implemented packet from the connection.
Definition: IPacket.cpp:33
IPacket & operator=(const IPacket &)
Definition: IPacket.cpp:12
virtual enum Type GetType() const =0
Get the Type of the packet.
virtual ~IPacket()
Definition: IPacket.cpp:29
virtual std::shared_ptr< IPacket > Clone() const =0
Create a new instance of the packet.
uint64_t m_connection_id
Definition: IPacket.hpp:161
virtual uint32_t Size() const =0
return the size of the packet in bytes, usually used to reserve the right amount of memory in the sen...
size_t SerializeHeader(uint8_t *buffer) const
util function to serialize the header of the packet will serialize the type and the size of the packe...
Definition: IPacket.cpp:41
void SetConnectionId(uint64_t connection_id)
Set the Connection Id ( eg source of the packet or destination if it's a response)
Definition: IPacket.hpp:140
virtual void Serialize(uint8_t *buffer) const =0
will write the packet in the buffer, the buffer must at least be of size Size()