|
Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
|
#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... | |
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.
|
inline |
Constructor which makes a Header normally
| size | Size in bytes of the data portion of the packet (not inc header) |
| type | Type of the packet, according to the PacketType enum |
|
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.
| buffer | The buffer received over the network containing the 4 bytes for the header. |
|
inline |
Converts this packet to network byte order. This should be called before sending over the network.
| uint16_t PacketHeader::size |
Size (in bytes) of the packet data (not including the header)
| PacketType PacketHeader::type |
What kind of packet this is, according to the Type enum class.