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
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
StormByte::Network::Packet Class Referenceabstract

The class representing a packet. Explicitelly instantiate this class to get packets identified by their opcode The buffer should contain the opcode and the data. More...

#include <packet.hxx>

Public Member Functions

 Packet (const Packet &other)=default
 The copy constructor of the Packet class.
 
 Packet (Packet &&other) noexcept=default
 The move constructor of the Packet class.
 
virtual ~Packet () noexcept=default
 The destructor of the Packet class.
 
Packetoperator= (const Packet &other)=default
 The assignment operator of the Packet class.
 
Packetoperator= (Packet &&other) noexcept=default
 The move assignment operator of the Packet class.
 
const Buffer::ConstByteSpan Data () const noexcept
 The function to get the opcode of the packet.
 
const unsigned short & Opcode () const noexcept
 The function to get the opcode of the packet.
 

Static Public Member Functions

static ExpectedPacket Read (const PacketInstanceFunction &pif, PacketReaderFunction reader) noexcept
 The function to get the packet instance.
 

Protected Member Functions

 Packet (const unsigned short &opcode) noexcept
 
virtual Expected< void, PacketErrorInitialize (PacketReaderFunction reader) noexcept=0
 The function to initialize the packet.
 

Protected Attributes

Buffer::Simple m_buffer
 The data buffer of the packet.
 

Detailed Description

The class representing a packet. Explicitelly instantiate this class to get packets identified by their opcode The buffer should contain the opcode and the data.

Constructor & Destructor Documentation

◆ Packet() [1/2]

StormByte::Network::Packet::Packet ( const Packet other)
default

The copy constructor of the Packet class.

Parameters
otherThe other Packet to copy.

◆ Packet() [2/2]

StormByte::Network::Packet::Packet ( Packet &&  other)
defaultnoexcept

The move constructor of the Packet class.

Parameters
otherThe other Packet to move.

Member Function Documentation

◆ Data()

const Buffer::ConstByteSpan StormByte::Network::Packet::Data ( ) const
noexcept

The function to get the opcode of the packet.

Returns
The opcode of the packet.

◆ Initialize()

virtual Expected< void, PacketError > StormByte::Network::Packet::Initialize ( PacketReaderFunction  reader)
protectedpure virtualnoexcept

The function to initialize the packet.

Returns
The expected result

◆ Opcode()

const unsigned short & StormByte::Network::Packet::Opcode ( ) const
noexcept

The function to get the opcode of the packet.

Returns
The opcode of the packet.

◆ operator=() [1/2]

Packet & StormByte::Network::Packet::operator= ( const Packet other)
default

The assignment operator of the Packet class.

Parameters
otherThe other Packet to assign.
Returns
The reference to the assigned Packet.

◆ operator=() [2/2]

Packet & StormByte::Network::Packet::operator= ( Packet &&  other)
defaultnoexcept

The move assignment operator of the Packet class.

Parameters
otherThe other Packet to assign.
Returns
The reference to the assigned Packet.

◆ Read()

static ExpectedPacket StormByte::Network::Packet::Read ( const PacketInstanceFunction pif,
PacketReaderFunction  reader 
)
staticnoexcept

The function to get the packet instance.

Parameters
pifThe packet instance function.
clientThe client socket.
Returns
The size of the packet.

The documentation for this class was generated from the following file: