group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
OutboundQueue Class Reference

Per-connection outbound message queue. More...

#include <OutboundQueue.hpp>

Public Member Functions

void enqueue (uint8_t replaceKey, std::vector< uint8_t > &&framedBytes)
 Enqueue a framed message.
bool flushTo (NET_StreamSocket *socket, Uint32 maxAgeMs)
 Drain the queue, writing each entry to socket.
size_t depth () const noexcept
 Number of entries currently queued (for telemetry / tests).
size_t totalBytes () const noexcept
 Total bytes across all queued entries (for telemetry).
void clear () noexcept
 Drop all queued entries (used on disconnect).

Private Attributes

std::deque< OutboundEntryentries_

Detailed Description

Per-connection outbound message queue.

Not thread-safe; each Connection owns one. The Server's broadcast helpers mutate it on the game thread; in stage 3b a dedicated network thread will drain it. For stage 3a everything runs on the game thread.

Member Function Documentation

◆ clear()

void OutboundQueue::clear ( )
inlinenoexcept

Drop all queued entries (used on disconnect).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ depth()

size_t OutboundQueue::depth ( ) const
inlinenodiscardnoexcept

Number of entries currently queued (for telemetry / tests).

◆ enqueue()

void OutboundQueue::enqueue ( uint8_t replaceKey,
std::vector< uint8_t > && framedBytes )

Enqueue a framed message.

Parameters
replaceKeySee OutboundEntry::replaceKey.
framedBytesBytes to send. Must already include the 4-byte length prefix that MessageStream uses for framing — this class doesn't add it.
Here is the caller graph for this function:

◆ flushTo()

bool OutboundQueue::flushTo ( NET_StreamSocket * socket,
Uint32 maxAgeMs )

Drain the queue, writing each entry to socket.

Entries older than maxAgeMs are dropped if their replaceKey is non-zero (i.e. unreliable-style snapshot/state). Reliable entries with replaceKey == 0 are always shipped regardless of age.

Parameters
socketSDL3_net stream socket to write to.
maxAgeMsDrop unreliable entries older than this (0 = no culling). Plan default: 300 ms.
Returns
False on socket error (caller should disconnect the client).

◆ totalBytes()

size_t OutboundQueue::totalBytes ( ) const
nodiscardnoexcept

Total bytes across all queued entries (for telemetry).

Member Data Documentation

◆ entries_

std::deque<OutboundEntry> OutboundQueue::entries_
private

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