vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetOutbox Class Reference

The sending half of messages that must arrive: once each, in the order sent. More...

#include <messages.h>

Public Member Functions

bool push (const uint8_t *bytes, size_t size)
 Keep size bytes to send.
size_t write (BitWriter &out, size_t budgetBits) const
 Write the oldest messages kept that fit in budgetBits.
void acknowledge (uint16_t newest)
 The other end has every message up to newest: stop sending them.
size_t pending () const
 Messages waiting to be acknowledged.
void clear ()
 Forget every message, and number the next one from the start.

Static Public Attributes

static constexpr uint32_t NONE_BITS = 1
 What write() writes when no message fits: the bit saying none follow.

Detailed Description

The sending half of messages that must arrive: once each, in the order sent.

A message is numbered and kept until the other end says it has it. Every packet carries every message still kept that fits, oldest first - the commands' answer to loss, not a retransmit timer - so a message rides each packet sent until one arrives, and the receiver drops the copies it already has.

Member Function Documentation

◆ push()

bool Vkm::Engine::NetOutbox::push ( const uint8_t * bytes,
size_t size )

Keep size bytes to send.

Parameters
bytesThe message.
sizeIts length, 1 to NET_MESSAGE_MAX_BYTES.
Returns
False, keeping nothing, when it is empty or too long, or NET_MESSAGE_WINDOW are waiting.

◆ write()

size_t Vkm::Engine::NetOutbox::write ( BitWriter & out,
size_t budgetBits ) const

Write the oldest messages kept that fit in budgetBits.

Always at least the one bit saying whether any follow.

Parameters
outThe packet.
budgetBitsRoom left in it.
Returns
How many were written.

◆ acknowledge()

void Vkm::Engine::NetOutbox::acknowledge ( uint16_t newest)

The other end has every message up to newest: stop sending them.

Parameters
newestThe latest sequence it has, as its acknowledgement says.

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