Header that starts every packet sent on an open connection.
More...
#include <protocol/PacketHeader.hpp>
|
|
std::uint32_t | connectionId = 0 |
| | Connection the packet belongs to.
|
| |
|
std::uint32_t | sequence = 0 |
| | Sequence number of this packet.
|
| |
|
std::uint32_t | ack = 0 |
| | Latest sequence received from the peer.
|
| |
|
std::uint32_t | ackBits = 0 |
| | Bitfield of the 32 previous sequences.
|
| |
|
|
static constexpr std::size_t | HEADER_SIZE = 16 |
| | Encoded size of the header, in bytes.
|
| |
Header that starts every packet sent on an open connection.
| Offset | Size | Field | Description |
| 0 | 4 | connectionId | Id given by the server in Welcome. |
| 4 | 4 | sequence | Sequence number of this packet. |
| 8 | 4 | ack | Latest sequence received from the peer. |
| 12 | 4 | ackBits | Bit i set if ack - 1 - i was received. |
◆ serialize()
Writes the header in network byte order.
- Parameters
-
| writer | Destination buffer. |
- Returns
- True on success, false if the buffer is full.
◆ deserialize()
Reads the header from a buffer.
- Parameters
-
- Returns
- True on success, false if fewer than 16 bytes remain.