|
VoltMod
C++23 framework for CS2 server plugins
|
Bookkeeping for ClientConVars: per-slot, cookie-keyed queries awaiting an answer. More...
#include <PendingConVarQueries.hpp>
Public Member Functions | |
| void | Prune (int slot, double now) |
| PendingConVarQuery * | Find (int slot, std::string_view name) |
| bool | Full (int slot) const |
| int | NextCookie (int slot) |
| void | Add (int slot, int cookie, std::string name, ClientConVars::QueryCallback callback, double now) |
| std::optional< PendingConVarQuery > | Take (int slot, int cookie, std::string_view name) |
| void | Clear (int slot) |
| void | ClearAll () |
| size_t | Count (int slot) const |
Static Public Attributes | |
| static constexpr size_t | MaxPendingPerSlot = 11 |
| static constexpr double | TimeoutSec = 10.0 |
| static constexpr uint32_t | MaxCookie = 0x7FFFFFFF |
Bookkeeping for ClientConVars: per-slot, cookie-keyed queries awaiting an answer.
Split out of the service so the matching and expiry rules are testable without the SDK. Time is caller-supplied (seconds, any monotonic origin) and expiry is lazy: nothing is dropped until the next Prune() for that slot, which the service runs on every Query().
A client need never answer, so the table is capped per slot - beyond MaxPendingPerSlot, queries are refused rather than queued behind a silent client.
Definition at line 34 of file PendingConVarQueries.hpp.
| void VoltMod::PendingConVarQueries::Add | ( | int | slot, |
| int | cookie, | ||
| std::string | name, | ||
| ClientConVars::QueryCallback | callback, | ||
| double | now | ||
| ) |
Track a query sent with a cookie from NextCookie.
Definition at line 63 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Definition at line 95 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
| void VoltMod::PendingConVarQueries::ClearAll | ( | ) |
Definition at line 103 of file PendingConVarQueries.cpp.
References VoltMod::ReadFile().
Definition at line 111 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by Full().
| PendingConVarQuery * VoltMod::PendingConVarQueries::Find | ( | int | slot, |
| std::string_view | name | ||
| ) |
The query for name already in flight on slot, or null.
Definition at line 20 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), VoltMod::PendingConVarQuery::Name, and VoltMod::ReadFile().
True when slot has no room for another query.
Definition at line 32 of file PendingConVarQueries.cpp.
References Count(), MaxPendingPerSlot, and VoltMod::ReadFile().
Next cookie unused on slot, or -1 when none could be found. Cookies increase monotonically and wrap back to 1 at MaxCookie.
Definition at line 37 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), MaxCookie, MaxPendingPerSlot, and VoltMod::ReadFile().
Drop slot's queries older than TimeoutSec. Their callbacks never fire.
Definition at line 9 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), VoltMod::ReadFile(), and TimeoutSec.
| std::optional< PendingConVarQuery > VoltMod::PendingConVarQueries::Take | ( | int | slot, |
| int | cookie, | ||
| std::string_view | name | ||
| ) |
Remove and return slot's query cookie, but only when name matches the convar it asked for: a client answering with a different name is answering a question nobody posed.
Definition at line 75 of file PendingConVarQueries.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Largest cookie handed out; the protobuf field is an int32.
Definition at line 44 of file PendingConVarQueries.hpp.
Referenced by NextCookie().
Outstanding queries allowed per slot before Query() starts refusing.
Definition at line 38 of file PendingConVarQueries.hpp.
Referenced by Full(), and NextCookie().
Age at which an unanswered query is dropped, in seconds.
Definition at line 41 of file PendingConVarQueries.hpp.
Referenced by Prune().