StormByte C++ Library: Network module 0.0.9999
StormByte-Network is a StormByte library module for handling and create network connections
Loading...
Searching...
No Matches
packet.hxx
1#pragma once
2
3#include <StormByte/network/typedefs.hxx>
4
5#include <memory>
6
11namespace StormByte::Network {
18 class STORMBYTE_NETWORK_PUBLIC Packet {
19 public:
24 Packet(const Packet& other) = default;
25
30 Packet(Packet&& other) noexcept = default;
31
35 virtual ~Packet() noexcept = default;
36
42 Packet& operator=(const Packet& other) = default;
43
49 Packet& operator=(Packet&& other) noexcept = default;
50
55 const Buffer::ConstByteSpan Data() const noexcept;
56
61 const unsigned short& Opcode() const noexcept;
62
70
71 protected:
72 Buffer::Simple m_buffer;
73
74 Packet(const unsigned short& opcode) noexcept;
75
80 virtual Expected<void, PacketError> Initialize(PacketReaderFunction reader) noexcept = 0;
81
82 private:
83 const unsigned short m_opcode;
84 };
85}
The class representing an error in the packet.
Definition exception.hxx:51
The class representing a packet. Explicitelly instantiate this class to get packets identified by the...
Definition packet.hxx:18
Packet(const Packet &other)=default
The copy constructor of the Packet class.
virtual ~Packet() noexcept=default
The destructor of the Packet class.
Packet(Packet &&other) noexcept=default
The move constructor of the Packet class.
The namespace containing read items.
Contains all the network-related classes and utilities.
Definition client.hxx:10
StormByte::Expected< std::shared_ptr< Packet >, PacketError > ExpectedPacket
The expected packet type.
Definition typedefs.hxx:37
std::function< ExpectedBuffer(const size_t &)> PacketReaderFunction
The packet reader function type.
Definition typedefs.hxx:39
std::function< std::shared_ptr< Packet >(const unsigned short &)> PacketInstanceFunction
The packet instance function type.
Definition typedefs.hxx:38