VOX
A little voxel engine
|
#include <PingPacket.hpp>
Public Member Functions | |
PingPacket () | |
PingPacket (uint64_t id, uint8_t counter) | |
PingPacket (const PingPacket &) | |
PingPacket & | operator= (const PingPacket &) |
PingPacket (PingPacket &&) | |
PingPacket & | operator= (PingPacket &&) |
~PingPacket () | |
void | Serialize (uint8_t *buffer) const override |
will write the packet in the buffer, the buffer must at least be of size Size() More... | |
void | Deserialize (const uint8_t *buffer) override |
read the packet from the buffer, the buffer must at least be of size Size() More... | |
uint32_t | Size () const override |
return the size of the packet in bytes, usually used to reserve the right amount of memory in the send buffer More... | |
bool | HasDynamicSize () const override |
Tell if the packet has a dynamic size. More... | |
enum Type | GetType () const override |
Get the Type of the packet. More... | |
std::shared_ptr< IPacket > | Clone () const override |
Create a new instance of the packet. More... | |
uint64_t | GetId () const |
void | SetId (uint64_t id) |
uint8_t | GetCounter () const |
void | SetCounter (uint8_t counter) |
Public Member Functions inherited from IPacket | |
virtual | ~IPacket () |
IPacket (const IPacket &) | |
IPacket & | operator= (const IPacket &) |
IPacket (IPacket &&) | |
IPacket & | operator= (IPacket &&) |
virtual void | Serialize (uint8_t *buffer) const =0 |
will write the packet in the buffer, the buffer must at least be of size Size() More... | |
void | ExtractMessage (Connection &connection) |
Extracts the implemented packet from the connection. More... | |
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 send buffer More... | |
virtual bool | HasDynamicSize () const =0 |
Tell if the packet has a dynamic size. More... | |
virtual enum Type | GetType () const =0 |
Get the Type of the packet. More... | |
virtual std::shared_ptr< IPacket > | Clone () const =0 |
Create a new instance of the packet. More... | |
uint64_t | GetConnectionId () const |
Get the Connection Id ( eg source of the packet or destination if it's a response) More... | |
void | SetConnectionId (uint64_t connection_id) |
Set the Connection Id ( eg source of the packet or destination if it's a response) More... | |
Additional Inherited Members | |
Public Types inherited from IPacket | |
enum class | Type : uint32_t { CONNECTION , PLAYER_CONNECTED , PLAYER_MOVE , DISCONNECT , BLOCK_ACTION , PING , PLAYER_LIST , CHUNK , CHUNK_REQUEST , CHUNK_UNLOAD , LOAD_DISTANCE , ENUM_MAX , ENUM_MIN = 0 } |
Static Public Attributes inherited from IPacket | |
static const uint32_t | STATIC_HEADER_SIZE = sizeof(Type) |
static const uint32_t | DYNAMIC_HEADER_SIZE = sizeof(Type) + sizeof(size_t) |
Protected Member Functions inherited from IPacket | |
virtual void | Deserialize (const uint8_t *buffer)=0 |
read the packet from the buffer, the buffer must at least be of size Size() More... | |
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 packet if it has a dynamic size More... | |
IPacket () | |
Protected Attributes inherited from IPacket | |
uint64_t | m_connection_id = 0 |
PingPacket::PingPacket | ( | ) |
PingPacket::PingPacket | ( | uint64_t | id, |
uint8_t | counter | ||
) |
PingPacket::PingPacket | ( | const PingPacket & | other | ) |
PingPacket::PingPacket | ( | PingPacket && | other | ) |
PingPacket::~PingPacket | ( | ) |
|
overridevirtual |
|
overridevirtual |
uint8_t PingPacket::GetCounter | ( | ) | const |
uint64_t PingPacket::GetId | ( | ) | const |
|
overridevirtual |
|
overridevirtual |
PingPacket & PingPacket::operator= | ( | const PingPacket & | other | ) |
PingPacket & PingPacket::operator= | ( | PingPacket && | other | ) |
|
overridevirtual |
void PingPacket::SetCounter | ( | uint8_t | counter | ) |
void PingPacket::SetId | ( | uint64_t | id | ) |
|
overridevirtual |
return the size of the packet in bytes, usually used to reserve the right amount of memory in the send buffer
or to check if a connection contains a complete packet
However you can still use it on an instance of a packet that has some data in it to estimate the size of the packet
Implements IPacket.