VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::NetChannels Class Reference

Per-client network-channel access: latency and the client's replicated userinfo cvars. More...

#include <NetChannel.hpp>

Public Member Functions

 NetChannels (Interfaces &interfaces)
 
INetChannelInfo * GetNetInfo (int slot) const
 
float EngineLatency (int slot) const
 
std::string_view GetUserInfoCvar (int slot, std::string_view name) const
 

Detailed Description

Per-client network-channel access: latency and the client's replicated userinfo cvars.

Stateless wrapper over IVEngineServer2: every call reads the engine live, so nothing here needs a lifecycle. Bots, empty slots and clients already torn down have no channel, and each accessor degrades to a null/zero result rather than asserting.

Definition at line 17 of file NetChannel.hpp.

Constructor & Destructor Documentation

◆ NetChannels()

VoltMod::NetChannels::NetChannels ( Interfaces &  interfaces)
inlineexplicit

interfaces supplies IVEngineServer2; it must outlive this service.

Definition at line 21 of file NetChannel.hpp.

Member Function Documentation

◆ EngineLatency()

float VoltMod::NetChannels::EngineLatency ( int  slot) const

Round-trip time in seconds, or 0 when the channel is unavailable.

Definition at line 16 of file NetChannel.cpp.

References GetNetInfo(), and VoltMod::ReadFile().

◆ GetNetInfo()

INetChannelInfo * VoltMod::NetChannels::GetNetInfo ( int  slot) const

The client's channel, or nullptr when slot has none (bot, empty, disconnecting).

Definition at line 10 of file NetChannel.cpp.

References VoltMod::Interfaces::Engine, VoltMod::IsValidSlot(), and VoltMod::ReadFile().

Referenced by EngineLatency().

◆ GetUserInfoCvar()

std::string_view VoltMod::NetChannels::GetUserInfoCvar ( int  slot,
std::string_view  name 
) const

The client's value for the userinfo convar name, or empty when the slot has no client, the engine is unavailable, or the client never sent one.

The view borrows the engine's own buffer, which the next userinfo update replaces: read it or copy it before returning to the engine, and never store it.

Definition at line 22 of file NetChannel.cpp.

References VoltMod::Interfaces::Engine, VoltMod::IsValidSlot(), and VoltMod::ReadFile().


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