VOX
A little voxel engine
Loading...
Searching...
No Matches
PingPacket.hpp
Go to the documentation of this file.
1#pragma once
2
3
4#include "IPacket.hpp"
5
6class PingPacket : public IPacket
7{
8public:
10 PingPacket(uint64_t id, uint8_t counter);
11 PingPacket(const PingPacket&);
16
17 void Serialize(uint8_t * buffer) const override;
18 void Deserialize(const uint8_t * buffer) override;
19 uint32_t Size() const override;
20 bool HasDynamicSize() const override;
21 enum Type GetType() const override;
22 std::shared_ptr<IPacket> Clone() const override;
23
24 uint64_t GetId() const;
25 void SetId(uint64_t id);
26
27 uint8_t GetCounter() const;
28 void SetCounter(uint8_t counter);
29private:
30 uint64_t m_id;
31 uint8_t m_counter;
32};
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
Type
Definition: IPacket.hpp:48
Definition: PingPacket.hpp:7
uint32_t Size() const override
return the size of the packet in bytes, usually used to reserve the right amount of memory in the sen...
Definition: PingPacket.cpp:71
void SetCounter(uint8_t counter)
Definition: PingPacket.cpp:106
void Deserialize(const uint8_t *buffer) override
read the packet from the buffer, the buffer must at least be of size Size()
Definition: PingPacket.cpp:59
uint8_t GetCounter() const
Definition: PingPacket.cpp:101
uint64_t GetId() const
Definition: PingPacket.cpp:91
PingPacket()
Definition: PingPacket.cpp:3
bool HasDynamicSize() const override
Tell if the packet has a dynamic size.
Definition: PingPacket.cpp:76
enum Type GetType() const override
Get the Type of the packet.
Definition: PingPacket.cpp:81
void Serialize(uint8_t *buffer) const override
will write the packet in the buffer, the buffer must at least be of size Size()
Definition: PingPacket.cpp:45
std::shared_ptr< IPacket > Clone() const override
Create a new instance of the packet.
Definition: PingPacket.cpp:86
~PingPacket()
Definition: PingPacket.cpp:41
void SetId(uint64_t id)
Definition: PingPacket.cpp:96
PingPacket & operator=(const PingPacket &)
Definition: PingPacket.cpp:23