group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Client.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
15#include "network/ShotDebugReport.hpp" // PR-20: shared wire-format + runtime capture struct.
16#include "network/ShotEvent.hpp"
20
21#include <SDL3/SDL_stdinc.h>
22
23#include <SDL3_net/SDL_net.h>
24#include <array>
25#include <atomic>
26#include <cstdint>
27#include <deque>
28#include <entt/entt.hpp>
29#include <mutex>
30#include <optional>
31#include <random>
32#include <thread>
33#include <utility>
34
37{
38 float rttMs = 0.0f;
39 float avgRttMs = 0.0f;
40 uint64_t bytesRecvTotal = 0;
41 uint64_t bytesSentTotal = 0;
42 float recvBytesPerSec = 0.0f;
43 float sendBytesPerSec = 0.0f;
44 uint32_t registryUpdateSize = 0;
45 float registryUpdatesPerSec = 0.0f;
46};
47
49class Client
50{
51public:
54 using SnapshotApplyCallback = std::function<bool(std::uint32_t snapshotTick,
55 const std::uint8_t* bytes,
56 Uint32 size,
57 Uint64 captureNs,
58 std::uint32_t& ackedTick)>;
60 using RawParticleEventCallback = std::function<void(const NetParticleEvent& evt)>;
61 using MatchStateUpdateFn = std::function<void(const MatchStatePacket&)>;
62 using KillEventCallback = std::function<void(const NetKillEvent&)>;
68 using ShotDebugCallback = std::function<void(const net::shotdebug::ShotDebugCapture&)>;
69
71 using LobbyUpdateCallback = std::function<void(const LobbyUpdateEvent& update)>;
73 using LobbyStateCallback = std::function<void(const std::vector<LobbyPlayer>& players, ClientId localId)>;
74
81 bool init(const char* addr, Uint16 port, const TransportConfig& transport = {});
82
84 void shutdown();
85
90 bool send(const void* data, uint32_t size);
91
102 bool sendInputSnapshot(const InputSnapshot& snap);
103
111 bool sendShotIntent(std::uint32_t shotInputTick, std::uint16_t targetClientId, const AnimSnapshot& targetAnim);
112
114 bool sendPlayerReady(bool ready);
115
117 bool sendStartMatch();
118
120 void sendPing();
121
123 void updateStats(float dt);
124
126 {
127 snapshotApplyFn_ = std::move(fn);
128 }
130 {
131 rawParticleEventFn_ = std::move(fn);
132 }
134 void onKillEvent(KillEventCallback fn) { killEventFn_ = std::move(fn); }
137 {
138 lobbyUpdateFn_ = std::move(fn);
139 }
141 {
142 lobbyStateFn_ = std::move(fn);
143 }
144
147 bool poll();
148
150 const NetworkStats& getNetStats() const { return stats; }
151
153 std::optional<MatchStatePacket> getLatestMatchState() const { return latestMatchState_; }
154
156 std::optional<std::pair<std::vector<LobbyPlayer>, ClientId>> getLatestLobbyState() const;
157
166 [[nodiscard]] uint32_t getServerAckedClientTick() const noexcept { return serverAckedClientTick_; }
167
173 [[nodiscard]] bool consumeSnapshotApplied() noexcept
174 {
175 const bool was = snapshotAppliedFlag_;
176 snapshotAppliedFlag_ = false;
177 return was;
178 }
179
200 [[nodiscard]] float getSnapshotAlpha() const;
201
204 [[nodiscard]] std::optional<entt::entity> getServerLocalPlayerEntity() const { return localPlayerEntity; }
205
225 [[nodiscard]] Uint64 getInterpolationRenderTimeNs() const;
226
231 [[nodiscard]] Uint64 getSnapshotIntervalNs() const;
232
267
269 void recordInterpolationSamples(Registry& registry, Uint64 captureNs);
270
276 static constexpr size_t k_inputRedundancy = 5;
277
298 void setSimulatedLatencyMs(int totalMs) noexcept;
299
301 [[nodiscard]] int getSimulatedLatencyMs() const noexcept
302 {
303 return simulatedLatencyMs_.load(std::memory_order_relaxed);
304 }
305
324 void setSimulatedLossPercent(int percent) noexcept;
325
327 [[nodiscard]] int getSimulatedLossPercent() const noexcept
328 {
329 return simulatedLossPercent_.load(std::memory_order_relaxed);
330 }
331
332private:
334 NET_Address* serverAddr = nullptr;
342 std::optional<entt::entity> localPlayerEntity;
343 std::optional<MatchStatePacket>
345 std::optional<std::vector<LobbyPlayer>> latestLobbyPlayers_;
346 std::optional<ClientId> latestLobbyLocalId_;
347
348 // ── PR-10 + PR-14 (server-perf): snapshot delta encoding state ────
349 //
350 // `keyframePayload_` holds the most-recent FULL snapshot's raw
351 // entt-serialized bytes (no PacketType prefix, no tick), and
352 // `keyframeTick_` is the tick that snapshot was sent at.
353 //
354 // PR-14 (loss resilience): both fields update *only* on FULL
355 // arrival. DELTA packets reconstruct the current frame's bytes
356 // by applying their patch on top of the keyframe and feed the
357 // reconstructed bytes into the Loader, but do NOT replace the
358 // saved keyframe. Pre-PR-14, every DELTA replaced the saved
359 // baseline with the just-reconstructed bytes — which meant a
360 // single dropped DELTA cascaded into all subsequent DELTAs in the
361 // same keyframe window dropping silently (their `fromTick` no
362 // longer matched the client's stored `lastSnapshotTick_`). Now
363 // every DELTA in a window is independently decodable against the
364 // shared keyframe, so individual packet drops only cost that one
365 // frame's state.
366 //
367 // If `fromTick` on a DELTA doesn't match `keyframeTick_` the
368 // packet is dropped — happens when a FULL keyframe was lost or
369 // hasn't arrived yet. The next periodic full keyframe (every 8
370 // snapshots ≈ 62 ms at 128 Hz) re-syncs us.
371 std::vector<uint8_t> keyframePayload_;
372 std::uint32_t keyframeTick_ = 0;
373
375
376 // Bandwidth tracking — accumulated between updateStats() calls.
377 uint64_t bytesSentWindow = 0;
378 uint64_t bytesRecvWindow = 0;
380 float statsAccumulator = 0.0f;
381
382 // Redundant input ring — see k_inputRedundancy and sendInputSnapshot().
383 // Stores the last N stamped InputSnapshots in chronological order so each
384 // outbound INPUT packet can include them all (server dedups by tick).
385 std::array<InputSnapshot, k_inputRedundancy> inputRing_{};
386 size_t inputRingHead_ = 0;
387 size_t inputRingCount_ = 0;
388
389 // ── Stage 3c: dedicated network thread ────────────────────────────────
390 //
391 // Symmetric to the server's stage 3b. The network thread continuously
392 // (a) pumps the kernel receive buffer into msgStream's recvBuf and
393 // (b) drains the outbound queue to the socket. The game thread keeps
394 // calling sendInputSnapshot / sendPing / poll() — those now
395 // touch the queue + recvBuf under stateMutex_ rather than doing
396 // syscalls inline. The win is that a render-frame stutter on the game
397 // thread no longer causes the kernel buffer to back up.
399 std::mutex stateMutex_;
400 std::thread networkThread_;
401 std::atomic<bool> shouldStop_{false};
402
406 std::atomic<bool> socketDead_{false};
407
408 // ── Phase 5a: snapshot-interval interpolation timing ──────────────────
409 //
410 // Updated whenever dispatchMessage applies an UPDATE_REGISTRY. The
411 // renderer reads getSnapshotAlpha() instead of the physics-tick alpha
412 // so motion stays smooth at the much-coarser snapshot rate. Both fields
413 // are 0 before any snapshot has been applied; getSnapshotAlpha returns
414 // 1.0 in that case so first frame draws the snapped position.
417
418 // ── PR-11: render-delay interpolation ────────────────────────────────
419 //
420 // `interpDelaySnapshots_` is read once at init() from the
421 // GROUP2_CLIENT_INTERP_DELAY_SNAPSHOTS env var (default 2). 0 disables
422 // the buffered render-delay path entirely; non-local entities
423 // fall back to the Phase-5a (prev, cur, alpha) lerp. Higher values
424 // smooth more loss but make remote entities visibly behind server
425 // truth. Source engine ships 2 (62.5 ms at 32 Hz) — that's our
426 // default and matches Valorant / Fortnite cadence.
427 //
428 // EMA of snapshot apply intervals. `prevSnapshotApplyNs_` and
429 // `lastSnapshotApplyNs_` already give a single most-recent interval;
430 // the EMA smooths burst arrivals so the render-delay computation
431 // doesn't wobble when packets arrive bunched. Snapshot rate doesn't
432 // change during a session, so a single-pole IIR with α=0.25 is
433 // ample. Initial value matches the design's 32 Hz snapshot rate.
434 // PR-13: 128 Hz default snapshot rate (AAA-pro cadence). EMA
435 // self-corrects once two snapshots have arrived if the actual
436 // rate differs (e.g. legacy server running at 32 Hz from a
437 // pre-PR-13 config.toml). The two-snapshot warmup window is
438 // ~16 ms at 128 Hz — fast enough that the initial value barely
439 // matters in practice.
440 static constexpr Uint64 k_defaultSnapshotIntervalNs = 1'000'000'000ULL / 128ULL;
441
442 // PR-19: re-enabled default = 2 snapshots after `Client::
443 // applyInterpolatedTransforms` started overwriting Position +
444 // InputSnapshot.yaw in place every frame. Now ALL visual
445 // consumers (renderer, tracers, ribbon trails, smoke emitters,
446 // beam endpoints, sfx) read from a single source of truth —
447 // `pos.value`, freshly written each frame to the interpolated
448 // value — so there's no more 6-unit body-vs-tracer separation
449 // that PR-16 was the emergency hotfix for.
450 //
451 // PR-16's history (kept for posterity): pre-PR-19, PR-11 wired
452 // `entity_interpolation::sample()` into 3 specific Game.cpp
453 // render sites only, missing TracerEffect / RibbonTrail /
454 // SmokeEffect / BeamState / sfx. PR-16 default-flipped this to
455 // 0 to disable the misaligned interp until PR-19's unified
456 // approach landed. PR-17 (FragmentReassembler stuck-state)
457 // turned out to be the bigger source of "models in wrong
458 // locations" — once that was fixed and PR-19 unifies the read
459 // path, default-on is safe again.
460 //
461 // To disable: set `GROUP2_CLIENT_INTERP_DELAY_SNAPSHOTS=0`.
464
465 // ── Phase 5b: prediction reconciliation hand-off ──────────────────────
466 //
467 // Updated by dispatchMessage on every UPDATE_REGISTRY apply. The game
468 // thread reads getServerAckedClientTick() + consumeSnapshotApplied() to
469 // know when and from which tick to replay client-stored inputs.
472
473 // ── Phase 3d: UDP sidecar ─────────────────────────────────────────────
474 //
475 // Bound during init() to any free local port. Server's address is
476 // resolved from the same hostname/port we connected over TCP. We
477 // stamp every outbound UDP datagram with the connectionId the
478 // server gave us in the ASSIGN_CLIENT_ID packet so it can match
479 // datagrams to our TCP-established Connection. Until that arrives
480 // we fall back to TCP for everything (connectionId == 0).
484 uint32_t connectionId_ = 0;
485 uint16_t udpInputSequence_ = 0;
486
492 std::vector<std::vector<uint8_t>> udpRecvQueue_;
493
500
510 bool reliableHasAny_ = false;
511
515 bool acceptReliableSequence(uint16_t seq);
516
517 // ── Phase 6 testing: latency simulator ────────────────────────────────
518 //
519 // Two FIFO queues — outbound packets that haven't reached the kernel
520 // socket yet, and inbound payloads that haven't been delivered to the
521 // game thread's dispatch queue yet. Both are drained at the top of
522 // each `networkLoop` cycle: any entry whose target counter has passed
523 // is sent (or enqueued for dispatch). Both share `stateMutex_` because
524 // the existing send/receive paths already hold it; piggy-backing
525 // avoids a second mutex.
526 //
527 // Sized to grow with traffic — typical worst case is 200 ms × 128 Hz
528 // INPUT × 1 client + ~32 Hz inbound snapshot stream ≈ 30 entries.
529
532 std::atomic<int> simulatedLatencyMs_{0};
533
537 std::atomic<int> simulatedLossPercent_{0};
538
544 std::mt19937 simLossRng_{};
545
549
552 {
555 std::vector<uint8_t> payload;
556 std::size_t totalBytes;
557 };
558 std::deque<DelayedOutbound> simLatOutbound_;
559
562 {
564 std::vector<uint8_t> payload;
565 };
566 std::deque<DelayedInbound> simLatInbound_;
567
574 bool sendUdpDelayed(net::PacketHeader hdr, const void* data, int len);
575
579 void recvUdpDelayed(std::vector<uint8_t>&& payload);
580
582 void networkLoop();
583
586 void dispatchMessage(const uint8_t* data, Uint32 size);
587
589 bool applySnapshot(std::uint32_t snapshotTick, const std::uint8_t* bytes, Uint32 size, Uint32 wireSize);
590};
PR-27 — per-entity animation state snapshot, decoupled from CharacterAnimator.
Per-connection assembly buffer for fragmented UDP packets.
Per-tick player input snapshot for networking and prediction.
Shared lobby data types exchanged between server and clients.
Shared definitions for match status and state synchronization between server and clients.
Length-prefixed message framing layer over a TCP stream socket.
Structure of kill event broadcasted from server to clients.
Network configuration loaded from config.toml at startup.
Per-client outbound message queue with replace-on-stale semantics.
Serialize and deserialize the entt ECS registry for network replication.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Wire-format types for the PR-20 lag-comp shot debug visualizer.
Wire-format particle effect event broadcast from server to all clients.
Thin wrapper over SDL3_net's NET_DatagramSocket.
TCP stream client — sends input to the server and receives state updates.
Definition Client.hpp:50
std::deque< DelayedInbound > simLatInbound_
Definition Client.hpp:566
size_t inputRingHead_
Next write index, wraps mod k_inputRedundancy.
Definition Client.hpp:386
static constexpr size_t k_inputRedundancy
Number of recent inputs included in each INPUT packet for redundancy.
Definition Client.hpp:276
void onSnapshotApply(SnapshotApplyCallback fn)
Register the snapshot-apply callback; must be set before the first poll().
Definition Client.hpp:125
net::UdpEndpoint udpEndpoint_
Definition Client.hpp:482
Uint64 snapshotIntervalEmaNs_
Definition Client.hpp:463
std::vector< std::vector< uint8_t > > udpRecvQueue_
UDP-received payloads waiting for the game thread to dispatch.
Definition Client.hpp:492
void sendPing()
Send a PING packet to the server for RTT measurement.
Definition Client.cpp:160
std::function< bool(std::uint32_t snapshotTick, const std::uint8_t *bytes, Uint32 size, Uint64 captureNs, std::uint32_t &ackedTick)> SnapshotApplyCallback
Called by Client to apply a raw snapshot; the registry-owning caller performs the actual load.
Definition Client.hpp:54
uint16_t reliableHighestSeen_
Phase 3d-5: sliding-window bitset for ReliableOrdered channel dedup.
Definition Client.hpp:508
std::function< void(const std::vector< LobbyPlayer > &players, ClientId localId)> LobbyStateCallback
Fired once on join with the full lobby snapshot and this client's assigned ID.
Definition Client.hpp:73
std::deque< DelayedOutbound > simLatOutbound_
Definition Client.hpp:558
bool consumeSnapshotApplied() noexcept
Whether a snapshot was applied since the last call to consumeSnapshotApplied().
Definition Client.hpp:173
std::optional< ClientId > latestLobbyLocalId_
This client's ID as reported in the LOBBY_STATE packet.
Definition Client.hpp:346
std::mutex stateMutex_
Definition Client.hpp:399
bool shouldDropPacketLocked()
Roll the loss RNG.
Definition Client.cpp:615
NET_Address * serverAddr
Resolved server address.
Definition Client.hpp:334
std::function< void(const LobbyUpdateEvent &update)> LobbyUpdateCallback
Fired for each incremental lobby roster update broadcast from the server.
Definition Client.hpp:71
uint64_t bytesSentWindow
Definition Client.hpp:377
std::thread networkThread_
Definition Client.hpp:400
void onLobbyUpdate(LobbyUpdateCallback fn)
Register the incremental lobby-update callback.
Definition Client.hpp:136
uint16_t udpInputSequence_
Per-channel sequence for INPUT datagrams.
Definition Client.hpp:485
uint32_t registryUpdatesWindow
Definition Client.hpp:379
bool snapshotAppliedFlag_
Definition Client.hpp:471
KillEventCallback killEventFn_
Called for each replicated kill event from server.
Definition Client.hpp:338
LobbyUpdateCallback lobbyUpdateFn_
Called for each lobby update received from server.
Definition Client.hpp:340
void shutdown()
Close the socket and release the resolved address.
Definition Client.cpp:101
std::optional< entt::entity > getServerLocalPlayerEntity() const
Server-assigned local-player entity before continuous_loader mapping.
Definition Client.hpp:204
void updateStats(float dt)
Update bandwidth stats. Call once per frame with the frame delta time.
Definition Client.cpp:201
bool poll()
Receive and process one pending message.
Definition Client.cpp:1145
std::optional< std::vector< LobbyPlayer > > latestLobbyPlayers_
Most-recent lobby roster received from the server.
Definition Client.hpp:345
int interpDelaySnapshots_
Definition Client.hpp:462
std::array< InputSnapshot, k_inputRedundancy > inputRing_
Definition Client.hpp:385
void recvUdpDelayed(std::vector< uint8_t > &&payload)
Enqueue an assembled UDP message into udpRecvQueue_ immediately if the simulator is off,...
Definition Client.cpp:662
std::function< void(const net::shotdebug::ShotDebugCapture &)> ShotDebugCallback
PR-20: callback for SHOT_DEBUG_REPORT.
Definition Client.hpp:68
const NetworkStats & getNetStats() const
Access current network statistics.
Definition Client.hpp:150
std::uint32_t keyframeTick_
Definition Client.hpp:372
void setSimulatedLossPercent(int percent) noexcept
Phase 6 testing: simulate UDP packet loss.
Definition Client.cpp:606
uint64_t reliableSeenBitmask_
Definition Client.hpp:509
bool sendShotIntent(std::uint32_t shotInputTick, std::uint16_t targetClientId, const AnimSnapshot &targetAnim)
PR-27 (netsync): send a SHOT_INTENT packet describing the client's view of the target's animation sta...
Definition Client.cpp:309
net::UdpEndpointAddr serverUdpAddr_
Definition Client.hpp:483
net::FragmentReassembler unreliableReassembler_
Phase 3d-4: reassembly buffer for fragmented snapshot datagrams on the Unreliable channel.
Definition Client.hpp:499
float getSnapshotAlpha() const
Render-time interpolation alpha based on snapshot timing.
Definition Client.cpp:415
Uint64 getInterpolationRenderTimeNs() const
Render time the renderer should display non-local entities at.
Definition Client.cpp:571
void recordInterpolationSamples(Registry &registry, Uint64 captureNs)
Record interpolation samples after the caller has applied a snapshot.
Definition Client.cpp:531
void onLobbyState(LobbyStateCallback fn)
Register the full lobby-snapshot callback, fired once on join.
Definition Client.hpp:140
Uint64 prevSnapshotApplyNs_
Definition Client.hpp:416
void onMatchStateUpdate(MatchStateUpdateFn fn)
Definition Client.hpp:133
void onShotDebugReport(ShotDebugCallback fn)
Definition Client.hpp:135
void networkLoop()
Network-thread main loop body.
Definition Client.cpp:680
float statsAccumulator
Definition Client.hpp:380
bool sendInputSnapshot(const InputSnapshot &snap)
Push the latest input into the redundant ring and send to the server.
Definition Client.cpp:215
TransportConfig transportConfig_
Definition Client.hpp:481
std::function< void(const NetKillEvent &)> KillEventCallback
Definition Client.hpp:62
ShotDebugCallback shotDebugFn_
PR-20: called for each SHOT_DEBUG_REPORT from server.
Definition Client.hpp:339
uint32_t serverAckedClientTick_
Definition Client.hpp:470
std::atomic< int > simulatedLossPercent_
Per-direction independent UDP-drop probability (slider value, 0–100).
Definition Client.hpp:537
void dispatchMessage(const uint8_t *data, Uint32 size)
Decode and dispatch a single complete framed message.
Definition Client.cpp:846
bool applySnapshot(std::uint32_t snapshotTick, const std::uint8_t *bytes, Uint32 size, Uint32 wireSize)
Invoke snapshotApplyFn_ with raw snapshot bytes; updates delta-decode state on success.
Definition Client.cpp:819
Uint64 lastSnapshotApplyNs_
Definition Client.hpp:415
std::vector< uint8_t > keyframePayload_
Definition Client.hpp:371
uint64_t bytesRecvWindow
Definition Client.hpp:378
void onKillEvent(KillEventCallback fn)
Definition Client.hpp:134
bool sendStartMatch()
Send a START_MATCH packet to the server (host-only).
Definition Client.cpp:361
std::function< void(const NetParticleEvent &evt)> RawParticleEventCallback
Called for each replicated particle event before entity mapping; caller is responsible for mapping.
Definition Client.hpp:60
uint32_t getServerAckedClientTick() const noexcept
Latest server-acked client predict tick.
Definition Client.hpp:166
std::atomic< bool > socketDead_
Latched-true once the network thread observes a socket error.
Definition Client.hpp:406
static constexpr Uint64 k_defaultSnapshotIntervalNs
Definition Client.hpp:440
uint32_t connectionId_
Definition Client.hpp:484
int getSimulatedLatencyMs() const noexcept
Get the currently-effective simulated total RTT.
Definition Client.hpp:301
size_t inputRingCount_
Valid entries in ring; saturates at k_inputRedundancy.
Definition Client.hpp:387
RawParticleEventCallback rawParticleEventFn_
Called for unmapped replicated particle events.
Definition Client.hpp:336
bool send(const void *data, uint32_t size)
Send a raw message to the server.
Definition Client.cpp:140
int getSimulatedLossPercent() const noexcept
Get the currently-effective simulated packet loss %.
Definition Client.hpp:327
std::atomic< int > simulatedLatencyMs_
Total simulated RTT in ms (slider value, 0–200).
Definition Client.hpp:532
MatchStateUpdateFn matchStateUpdateFn_
Called whenever a MATCH_STATE packet is received.
Definition Client.hpp:337
void onRawParticleEvent(RawParticleEventCallback fn)
Register the raw particle-event callback.
Definition Client.hpp:129
std::optional< MatchStatePacket > latestMatchState_
Most-recent MATCH_STATE packet; populated by dispatchMessage.
Definition Client.hpp:344
void applyInterpolatedTransforms(Registry &registry)
PR-19: overwrite Position.value (and InputSnapshot.yaw) for every non-local entity with an Interpolat...
Definition Client.cpp:445
SnapshotApplyCallback snapshotApplyFn_
Applies snapshot bytes in the registry-owning caller.
Definition Client.hpp:335
MessageStream msgStream
Framed message stream for server communication.
Definition Client.hpp:333
bool acceptReliableSequence(uint16_t seq)
Sliding-window dedup helper.
Definition Client.cpp:375
NetworkStats stats
Live network metrics.
Definition Client.hpp:374
std::optional< std::pair< std::vector< LobbyPlayer >, ClientId > > getLatestLobbyState() const
Return the latest lobby roster received from the server, if any.
Definition Client.cpp:367
std::function< void(const MatchStatePacket &)> MatchStateUpdateFn
Definition Client.hpp:61
std::atomic< bool > shouldStop_
Definition Client.hpp:401
std::optional< MatchStatePacket > getLatestMatchState() const
Return the latest match state packet received from the server, if any.
Definition Client.hpp:153
bool sendUdpDelayed(net::PacketHeader hdr, const void *data, int len)
Send a UDP datagram immediately if the latency simulator is off, otherwise queue it for delayed send.
Definition Client.cpp:628
bool init(const char *addr, Uint16 port, const TransportConfig &transport={})
Create the TCP socket and connect to the server.
Definition Client.cpp:28
bool reliableHasAny_
False until the first reliable event arrives.
Definition Client.hpp:510
std::optional< entt::entity > localPlayerEntity
The local player's entity, once assigned by the server.
Definition Client.hpp:342
void setSimulatedLatencyMs(int totalMs) noexcept
Phase 6 testing: simulate added round-trip latency.
Definition Client.cpp:593
OutboundQueue outbound_
Definition Client.hpp:398
LobbyStateCallback lobbyStateFn_
Called once on join with the full lobby snapshot.
Definition Client.hpp:341
bool sendPlayerReady(bool ready)
Send a PLAYER_READY or PLAYER_UNREADY packet to the server.
Definition Client.cpp:355
std::mt19937 simLossRng_
PRNG for the loss simulator.
Definition Client.hpp:544
Uint64 getSnapshotIntervalNs() const
Approximate snapshot interval in nanoseconds.
Definition Client.cpp:440
Length-prefixed framing layer over a TCP stream socket.
Definition MessageStream.hpp:29
Per-connection outbound message queue.
Definition OutboundQueue.hpp:85
Definition FragmentReassembler.hpp:33
Wraps a NET_DatagramSocket with header-prefixed I/O.
Definition UdpEndpoint.hpp:77
Snapshot of an entity's full animation state at one instant.
Definition AnimSnapshot.hpp:73
Associates an entity with a connected network client.
Definition ClientId.hpp:10
One inbound payload queued for delayed dispatch.
Definition Client.hpp:562
Uint64 deliverAtCounter
Performance counter at which to enqueue.
Definition Client.hpp:563
std::vector< uint8_t > payload
Already-assembled message ([PacketType][rest]).
Definition Client.hpp:564
One outbound UDP datagram queued for delayed send.
Definition Client.hpp:552
std::vector< uint8_t > payload
Datagram payload bytes.
Definition Client.hpp:555
Uint64 sendAtCounter
Performance counter at which to send.
Definition Client.hpp:553
net::PacketHeader header
Caller-supplied header (passed through verbatim).
Definition Client.hpp:554
std::size_t totalBytes
For deferred bandwidth accounting.
Definition Client.hpp:556
One tick of player input, stamped with the tick it was sampled on.
Definition InputSnapshot.hpp:17
Incremental lobby change event broadcast to all connected clients.
Definition LobbyStatus.hpp:28
Definition MatchStatus.hpp:15
Event representing a player kill, sent from server to client for kill feed updates.
Definition NetKillEvent.hpp:12
Wire-format particle event broadcast from server to all clients.
Definition ShotEvent.hpp:27
Live network statistics updated each frame.
Definition Client.hpp:37
float registryUpdatesPerSec
Registry updates received per second.
Definition Client.hpp:45
float avgRttMs
Exponential moving average RTT (ms).
Definition Client.hpp:39
uint32_t registryUpdateSize
Last registry update payload size (bytes).
Definition Client.hpp:44
float rttMs
Latest round-trip time (ms).
Definition Client.hpp:38
uint64_t bytesSentTotal
Total bytes sent since connection.
Definition Client.hpp:41
float recvBytesPerSec
Receive bandwidth (bytes/sec, smoothed).
Definition Client.hpp:42
float sendBytesPerSec
Send bandwidth (bytes/sec, smoothed).
Definition Client.hpp:43
uint64_t bytesRecvTotal
Total bytes received since connection.
Definition Client.hpp:40
Phase 3d: per-feature toggles for the UDP transport rollout.
Definition NetworkConfig.hpp:63
16-byte header at the start of every UDP datagram we send.
Definition PacketHeader.hpp:102
A UDP datagram address (server's view of a remote peer).
Definition UdpEndpoint.hpp:49
Server-side runtime capture of one shot's debug data, produced by WeaponSystem::handleFire and consum...
Definition ShotDebugReport.hpp:111