VOX
A little voxel engine
Loading...
Searching...
No Matches
ConnectionPacket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IPacket.hpp"
4#include "glm/vec3.hpp"
5
7{
8public:
10 ConnectionPacket(uint32_t id, glm::vec3 position);
12
15
18
19
20 void Serialize(uint8_t * buffer) const override;
21 void Deserialize(const uint8_t * buffer) override;
22 uint32_t Size() const override;
23 bool HasDynamicSize() const override;
24 IPacket::Type GetType() const override;
25
26 std::shared_ptr<IPacket> Clone() const override;
27
28 /*****************************\
29 * ATTRIBUTES
30 \*****************************/
31
32 uint32_t GetPlayerId() const;
33 glm::vec3 GetPosition() const;
34
35 void SetPlayerId(uint32_t id);
36 void SetPosition(glm::vec3 position);
37private:
38 uint32_t m_player_id;
39 glm::vec3 m_position;
40};
Definition: ConnectionPacket.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: ConnectionPacket.cpp:72
std::shared_ptr< IPacket > Clone() const override
Create a new instance of the packet.
Definition: ConnectionPacket.cpp:82
void SetPosition(glm::vec3 position)
Definition: ConnectionPacket.cpp:107
bool HasDynamicSize() const override
Tell if the packet has a dynamic size.
Definition: ConnectionPacket.cpp:77
ConnectionPacket & operator=(const ConnectionPacket &other)
Definition: ConnectionPacket.cpp:17
void Deserialize(const uint8_t *buffer) override
read the packet from the buffer, the buffer must at least be of size Size()
Definition: ConnectionPacket.cpp:60
uint32_t GetPlayerId() const
Definition: ConnectionPacket.cpp:92
ConnectionPacket()
Definition: ConnectionPacket.cpp:3
void SetPlayerId(uint32_t id)
Definition: ConnectionPacket.cpp:102
void Serialize(uint8_t *buffer) const override
will write the packet in the buffer, the buffer must at least be of size Size()
Definition: ConnectionPacket.cpp:46
IPacket::Type GetType() const override
Get the Type of the packet.
Definition: ConnectionPacket.cpp:87
glm::vec3 GetPosition() const
Definition: ConnectionPacket.cpp:97
~ConnectionPacket()
Definition: ConnectionPacket.cpp:42
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
Type
Definition: IPacket.hpp:48