|
group2 0.1.0
CSE 125 Group 2
|
Per-client connection state. More...
Classes | |
| struct | PendingReliableEvent |
| Phase 3d-5: pending reliable events, each scheduled for remainingSends more cycles. More... | |
Public Attributes | |
| MessageStream | msgStream |
| Framed message stream for this client. | |
| ClientId | clientId |
| Unique identifier assigned on accept. | |
| bool | pendingInitialization |
| True if waiting for Game to initialize player entity. | |
| uint32_t | lastAppliedInputTick = 0 |
| Highest InputSnapshot.tick this client has had applied to the simulation. | |
| OutboundQueue | outbound |
| Per-client userspace outbound queue (Phase 3a). | |
| uint32_t | connectionId = 0 |
| Phase 3d: server-assigned UDP connection ID. | |
| net::UdpEndpointAddr | udpAddr |
| Phase 3d: source address of the most-recent UDP packet from this client. | |
| uint16_t | udpSnapshotSequence = 0 |
| Phase 3d-4: per-client outgoing sequence for the Unreliable channel's snapshot stream. | |
| uint16_t | reliableNextSequence = 0 |
| Phase 3d-5: per-client outgoing sequence for the reliable event stream over UDP. | |
| std::deque< PendingReliableEvent > | reliableQueue |
| uint16_t | lastReportedRttMs = 0 |
| Phase 6: client's most-recent self-reported smoothed RTT in milliseconds. | |
Per-client connection state.
| ClientId Server::Connection::clientId |
Unique identifier assigned on accept.
| uint32_t Server::Connection::connectionId = 0 |
Phase 3d: server-assigned UDP connection ID.
Generated when the TCP connection is accepted and shipped to the client in the ASSIGN_CLIENT_ID packet. Clients stamp every outbound UDP datagram with this; the server demuxes incoming UDP via connIdToClient_ to find which TCP-established client the datagram is from. 0 = not yet assigned.
| uint32_t Server::Connection::lastAppliedInputTick = 0 |
Highest InputSnapshot.tick this client has had applied to the simulation.
Used to dedup multi-input redundancy: each client sends the last N inputs every tick, so most arrivals are duplicates of already-applied data. We accept only inputs strictly newer than this value and update it as we process. Resets to 0 on reconnect because each Connection is constructed fresh.
| uint16_t Server::Connection::lastReportedRttMs = 0 |
Phase 6: client's most-recent self-reported smoothed RTT in milliseconds.
Updated on every INPUT packet (the 2-byte rttMs prefix in the wire format). Read by the lag-compensation scheduler each server tick to size this client's hitscan rewind window — targetServerTick = currentServerTick - clamp(rttMs/2 → ticks, 0, k_maxLagCompTicks). Stays at 0 until the first INPUT packet arrives, which means brand-new connections start with no rewind (correct: their PING/PONG hasn't completed yet so any rewind would be guesswork).
| MessageStream Server::Connection::msgStream |
Framed message stream for this client.
| OutboundQueue Server::Connection::outbound |
Per-client userspace outbound queue (Phase 3a).
All broadcast helpers push into this queue; the queue is then flushed once at end-of-tick via flushAllOutbound(). The replace-on-stale semantics mean a slow drainer only ever has one pending UPDATE_REGISTRY in flight (always the freshest), instead of accumulating dozens of obsolete snapshots in SDL3_net's internal pending_output_buffer.
| bool Server::Connection::pendingInitialization |
True if waiting for Game to initialize player entity.
| uint16_t Server::Connection::reliableNextSequence = 0 |
Phase 3d-5: per-client outgoing sequence for the reliable event stream over UDP.
Each pushed event gets next-sequence; client dedups against a sliding-window bitset of recently-seen sequences.
| std::deque<PendingReliableEvent> Server::Connection::reliableQueue |
| net::UdpEndpointAddr Server::Connection::udpAddr |
Phase 3d: source address of the most-recent UDP packet from this client.
Filled in lazily on first UDP receive (the client's actual UDP source port isn't known until then — it's auto-assigned by their kernel). Server uses this to route UDP replies (PONG, future server→client UDP traffic).
| uint16_t Server::Connection::udpSnapshotSequence = 0 |
Phase 3d-4: per-client outgoing sequence for the Unreliable channel's snapshot stream.
Increments on every snapshot the server sends to this client. Receiver uses it to drop stale fragments when a newer set arrives.