VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
NetChannel.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <string_view>
6
7namespace VoltMod
8{
9
10/**
11 * @brief Per-client network-channel access: latency and the client's replicated userinfo cvars.
12 *
13 * Stateless wrapper over IVEngineServer2: every call reads the engine live, so nothing here needs a
14 * lifecycle. Bots, empty slots and clients already torn down have no channel, and each accessor
15 * degrades to a null/zero result rather than asserting.
16 */
18{
19public:
20 /** @p interfaces supplies IVEngineServer2; it must outlive this service. */
21 explicit NetChannels(Interfaces& interfaces) : _interfaces(interfaces) {}
22
23 /** The client's channel, or nullptr when @p slot has none (bot, empty, disconnecting). */
25
26 /** Round-trip time in seconds, or 0 when the channel is unavailable. */
27 float EngineLatency(int slot) const;
28
29 /**
30 * The client's value for the userinfo convar @p name, or empty when the slot has no client,
31 * the engine is unavailable, or the client never sent one.
32 *
33 * The view borrows the engine's own buffer, which the next userinfo update replaces: read it
34 * or copy it before returning to the engine, and never store it.
35 */
36 std::string_view GetUserInfoCvar(int slot, std::string_view name) const;
37
38private:
39 Interfaces& _interfaces;
40};
41
42} // namespace VoltMod
Per-client network-channel access: latency and the client's replicated userinfo cvars.
std::string_view GetUserInfoCvar(int slot, std::string_view name) const
NetChannels(Interfaces &interfaces)
float EngineLatency(int slot) const
INetChannelInfo * GetNetInfo(int slot) const
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
Centralized holder for all HL2SDK interface pointers.