Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
aegis2d::net::AckTracker Class Reference

Receiver side of the acknowledgements: which datagrams of the peer arrived. More...

#include <aegis2d/net/reliability.hpp>

Public Member Functions

bool record (std::uint16_t sequence) noexcept
 Records the sequence of a datagram received from the peer.
 
std::uint16_t ack () const noexcept
 The ack field to send.
 
std::uint32_t ack_bits () const noexcept
 The ack_bits field to send.
 
bool received_any () const noexcept
 Tells whether any datagram was recorded.
 

Detailed Description

Receiver side of the acknowledgements: which datagrams of the peer arrived.

Gives the ack and ack_bits fields of the next datagram sent to the peer: the most recent sequence received, and one bit for each of the 32 before it. Before anything is received, ack is 65535, the sequence before the peer's first one (0), and ack_bits is 0 (RFC section 5.1).

Member Function Documentation

◆ ack()

std::uint16_t aegis2d::net::AckTracker::ack ( ) const
inlinenoexcept

The ack field to send.

Returns
The most recent sequence received, or 65535 before anything was received.

◆ ack_bits()

std::uint32_t aegis2d::net::AckTracker::ack_bits ( ) const
inlinenoexcept

The ack_bits field to send.

Returns
Bit n set when sequence ack() - 1 - n was received.

◆ received_any()

bool aegis2d::net::AckTracker::received_any ( ) const
inlinenoexcept

Tells whether any datagram was recorded.

Returns
false until the first record().

◆ record()

bool aegis2d::net::AckTracker::record ( std::uint16_t  sequence)
noexcept

Records the sequence of a datagram received from the peer.

Call it only for datagrams whose header and payload are valid: a dropped datagram must not be acknowledged.

Parameters
sequenceThe datagram's sequence field.
Returns
true for a datagram not seen before; false for a duplicate, or for one older than the 32 sequences before ack (or 32768 away from it), which is not acknowledged.

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