Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
PacketHeader Struct Reference

#include <packet.hpp>

Public Member Functions

 PacketHeader (uint16_t size, PacketType type)
 
void to_network ()
 
 PacketHeader (void *buffer)
 

Data Fields

uint16_t size
 Size (in bytes) of the packet data (not including the header) More...
 
PacketType type
 What kind of packet this is, according to the Type enum class. More...
 

Detailed Description

Header for any arbitrary packet on the network sent by our game. Headers are sent as POD (plain-old-data), so the recipient can always read exactly sizeof(Header), get the relevant information of the packet, and then use boost::serialization to deserialize the more complicated Packet types below.

Constructor & Destructor Documentation

◆ PacketHeader() [1/2]

PacketHeader::PacketHeader ( uint16_t  size,
PacketType  type 
)
inline

Constructor which makes a Header normally

Parameters
sizeSize in bytes of the data portion of the packet (not inc header)
typeType of the packet, according to the PacketType enum

◆ PacketHeader() [2/2]

PacketHeader::PacketHeader ( void buffer)
inlineexplicit

Constructor which takes a buffer received over the network and constructs a Header object from it. It assumes that the packet is in network byte order so this should not be used if the buffer contains a packet header not in network byte order.

Parameters
bufferThe buffer received over the network containing the 4 bytes for the header.

Member Function Documentation

◆ to_network()

void PacketHeader::to_network ( )
inline

Converts this packet to network byte order. This should be called before sending over the network.

Field Documentation

◆ size

uint16_t PacketHeader::size

Size (in bytes) of the packet data (not including the header)

◆ type

PacketType PacketHeader::type

What kind of packet this is, according to the Type enum class.


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