Description
The Stats
property of the Connection
class provides detailed statistics about the network connection. This includes information such as bandwidth usage and the number of packets being sent and received. This property is useful for monitoring and analyzing the performance and reliability of a network connection.
Usage
To access the connection statistics, you can use the Stats
property on an instance of the Connection
class. This property returns an instance of Sandbox.Network.ConnectionStats
, which contains various metrics related to the connection.
Example
// Example of accessing connection stats
Connection connection = Connection.Find(someGuid);
Sandbox.Network.ConnectionStats stats = connection.Stats;
// Display some stats
float bandwidthUsage = stats.BandwidthUsage;
int packetsSent = stats.PacketsSent;
int packetsReceived = stats.PacketsReceived;
// Use the stats for monitoring or logging
// (Assuming you have a method to log or display these values)
LogConnectionStats(bandwidthUsage, packetsSent, packetsReceived);