VOX
A little voxel engine
Loading...
Searching...
No Matches
PacketFactory.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_map>
4
5#include "Packets.hpp"
6
8{
9public:
11
12 PacketFactory(const PacketFactory& other) = delete;
13 PacketFactory& operator=(const PacketFactory& other) = delete;
14
15 PacketFactory(PacketFactory&& other) = delete;
17
22 static PacketFactory& GetInstance();
23
30 std::pair<bool, std::shared_ptr<IPacket> > extractPacket(Connection & connection);
31private:
36 struct packetInfo
37 {
42 bool complete;
43
48 IPacket::Type type;
49
54 ssize_t size;
55 };
56
63
71 packetInfo getPacketInfo(const uint8_t * buffer, const size_t & size) const;
72
87 std::unordered_map<IPacket::Type, std::shared_ptr<IPacket>> m_packets;
88};
a bufferised and thread safe RAII wrapper for a socket representing a connection.
Definition: Connection.hpp:29
Type
Definition: IPacket.hpp:48
Definition: PacketFactory.hpp:8
~PacketFactory()
Definition: PacketFactory.cpp:33
PacketFactory(PacketFactory &&other)=delete
PacketFactory(const PacketFactory &other)=delete
PacketFactory & operator=(const PacketFactory &other)=delete
std::pair< bool, std::shared_ptr< IPacket > > extractPacket(Connection &connection)
Will try to extract a packet from the connection's buffer.
Definition: PacketFactory.cpp:93
PacketFactory & operator=(PacketFactory &&other)=delete
static PacketFactory & GetInstance()
Get a ref to the singleton instance of the PacketFactory.
Definition: PacketFactory.cpp:110