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

Per-client network access: latency, userids, usercmd status and the client's replicated userinfo cvars. More...

#include <NetChannel.hpp>

Public Member Functions

 NetChannels (Interfaces &interfaces)
INetChannelInfo * GetNetInfo (int slot) const
bool HasClient (int slot) const
float EngineLatency (int slot) const
int GetUserId (int slot) const
std::optional< CommandStatus > GetCommandStatus (int slot) const
std::string_view GetUserInfoCvar (int slot, std::string_view name) const

Detailed Description

Per-client network access: latency, userids, usercmd status and the client's replicated userinfo cvars.

Stateless wrapper over IVEngineServer2 and ISource2GameClients: 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 32 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 36 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 17 of file NetChannel.cpp.

References GetNetInfo().

◆ GetCommandStatus()

std::optional< CommandStatus > VoltMod::NetChannels::GetCommandStatus ( int slot) const

How the server is keeping up with slot's usercmds, or empty when it has no player. A rising gap between received and executed, or starved and discarded ticks, is how fakelag shows.

Definition at line 35 of file NetChannel.cpp.

References VoltMod::IsValidSlot().

◆ GetNetInfo()

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

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

Definition at line 11 of file NetChannel.cpp.

References VoltMod::IsValidSlot().

Referenced by EngineLatency(), and HasClient().

◆ GetUserId()

int VoltMod::NetChannels::GetUserId ( int slot) const

The userid game events name the player by, or -1 when slot is empty. Bots have one too.

Definition at line 23 of file NetChannel.cpp.

References VoltMod::IsValidSlot().

◆ 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 53 of file NetChannel.cpp.

References VoltMod::IsValidSlot().

◆ HasClient()

bool VoltMod::NetChannels::HasClient ( int slot) const
inline

Whether slot holds a human client: false for a bot, an empty slot or one disconnecting.

Definition at line 42 of file NetChannel.hpp.

References GetNetInfo().


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