|
Aegis2D
Modular C++26 2D game engine for networked games
|
Header at the start of every UDP datagram. More...
#include <aegis2d/net/packet.hpp>
Public Member Functions | |
| bool | operator== (const PacketHeader &) const =default |
| Field-by-field equality. | |
Public Attributes | |
| PacketType | type = PacketType::Heartbeat |
| What the datagram carries. | |
| std::uint16_t | sequence = 0 |
| Number of this datagram, incremented by the sender for each one and wrapping from 65535 to 0. | |
| std::uint16_t | ack = 0 |
| Most recent sequence number received from the peer. | |
| std::uint32_t | ack_bits = 0 |
Bit n set: sequence ack - 1 - n was received too. | |
| std::uint32_t | session = 0 |
| Session token issued by the TCP login; 0 is never issued. | |
| bool | compressed = false |
Whether the payload is compressed (see aegis2d/net/compression.hpp). | |
Static Public Attributes | |
| static constexpr std::uint32_t | magic = 0x50595452 |
First four bytes of every datagram: 52 54 59 50, "RTYP" in ASCII. | |
| static constexpr std::uint8_t | version = 1 |
| Protocol version; peers with another version are not understood. | |
| static constexpr std::size_t | size = 18 |
| Size of the header on the wire, in bytes. | |
| static constexpr std::size_t | max_payload_size = max_datagram_size - size |
| Largest payload after the header. | |
| static constexpr std::uint8_t | compressed_flag = 0x80 |
| Bit of the type byte set when the payload is compressed. | |
Header at the start of every UDP datagram.
On the wire: magic (u32), version (u8), type (u8), sequence (u16), ack (u16), ack_bits (u32), session (u32), little-endian, 18 bytes. The magic and the version are constants written by write_header() and checked by read_header(); the other fields are below. The type byte carries the type in its 7 low bits and compressed in its high bit.
|
default |
Field-by-field equality.
true if every field is equal. | std::uint16_t aegis2d::net::PacketHeader::ack = 0 |
Most recent sequence number received from the peer.
| std::uint32_t aegis2d::net::PacketHeader::ack_bits = 0 |
Bit n set: sequence ack - 1 - n was received too.
| bool aegis2d::net::PacketHeader::compressed = false |
Whether the payload is compressed (see aegis2d/net/compression.hpp).
|
staticconstexpr |
Bit of the type byte set when the payload is compressed.
|
staticconstexpr |
First four bytes of every datagram: 52 54 59 50, "RTYP" in ASCII.
|
staticconstexpr |
Largest payload after the header.
| std::uint16_t aegis2d::net::PacketHeader::sequence = 0 |
Number of this datagram, incremented by the sender for each one and wrapping from 65535 to 0.
| std::uint32_t aegis2d::net::PacketHeader::session = 0 |
Session token issued by the TCP login; 0 is never issued.
|
staticconstexpr |
Size of the header on the wire, in bytes.
| PacketType aegis2d::net::PacketHeader::type = PacketType::Heartbeat |
What the datagram carries.
|
staticconstexpr |
Protocol version; peers with another version are not understood.