Table of Contents

Class ServerStatsCollector

Namespace
EchoHub.Server.Services.Stats
Assembly
EchoHub.Server.dll

Thread-safe, in-memory accumulator for server-activity counters that have no natural database timestamp to query after the fact — session connects/disconnects, moderation actions, and peak concurrency. The periodic stats-report job snapshots and resets these once per reporting window. Registered as a singleton; every increment is lock-free so it is safe to call from hot paths (connect/disconnect).

public sealed class ServerStatsCollector
Inheritance
ServerStatsCollector
Inherited Members

Constructors

ServerStatsCollector()

public ServerStatsCollector()

Methods

RecordBan()

Record a ban action.

public void RecordBan()

RecordConnection(int)

Record a session coming online, updating the running peak.

public void RecordConnection(int onlineNow)

Parameters

onlineNow int

RecordDisconnection(int)

Record a session going offline, updating the running peak.

public void RecordDisconnection(int onlineNow)

Parameters

onlineNow int

RecordKick()

Record a kick action.

public void RecordKick()

RecordOnline(int)

Update the running maximum of concurrent online users (lock-free).

public void RecordOnline(int onlineNow)

Parameters

onlineNow int

SnapshotAndReset(int)

Atomically read all counters and reset them for the next reporting window. The peak is reset to onlineNow so the next window's peak starts from the current concurrency rather than zero.

public StatsCounters SnapshotAndReset(int onlineNow)

Parameters

onlineNow int

Returns

StatsCounters