xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
Packet.h
Go to the documentation of this file.
1#ifndef NET_PACKET_H
2#define NET_PACKET_H
3
7
8#include <cstring>
9
10namespace Xale::Net
11{
15 class Packet : public IPacket {
16 private:
20 CommandType command;
24 std::vector<uint8_t> payload;
28 std::vector<uint8_t> token;
29 public:
36 Packet(CommandType cmd, std::vector<uint8_t> data, std::vector<uint8_t> tokenData = {});
41 std::vector<uint8_t> serialize() const override;
46 void deserialize(const std::vector<uint8_t>& buffer) override;
47
52 uint32_t size() const override;
53
58 const std::vector<uint8_t> getPayload() const;
59 };
60}
61
62#endif // NET_PACKET_H
Definition IPacket.h:10
uint32_t size() const override
Gets the total size of the packet in bytes.
Definition Packet.cpp:81
Packet(CommandType cmd, std::vector< uint8_t > data, std::vector< uint8_t > tokenData={})
Constructs a Packet with command, payload, and optional token.
Definition Packet.cpp:11
void deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the packet from a byte vector.
Definition Packet.cpp:45
std::vector< uint8_t > serialize() const override
Serializes the packet to a byte vector.
Definition Packet.cpp:19
const std::vector< uint8_t > getPayload() const
Gets the payload data of the packet.
Definition Packet.cpp:90
Definition IPacket.h:8
CommandType
Definition PacketConstants.h:12