using System;
namespace axXez.TS3.Protocol
{
/// Detailed per-connection network statistics returned by serverrequestconnectioninfo.
public class ConnectionInfo : TsEntity, INetworkStats
{
/// Current outgoing file transfer bandwidth in bytes/s.
[TsField("connection_filetransfer_bandwidth_sent")]
public int CurrentOutgoingFileTransferBandwidth { get; protected set; }
/// Current incoming file transfer bandwidth in bytes/s.
[TsField("connection_filetransfer_bandwidth_received")]
public int CurrentIncomingFileTransferBandwidth { get; protected set; }
/// Total bytes sent via file transfer.
[TsField("connection_filetransfer_bytes_sent_total")]
public long TotalFileTransferBytesSent { get; protected set; }
/// Total bytes received via file transfer.
[TsField("connection_filetransfer_bytes_received_total")]
public long TotalFileTransferBytesReceived { get; protected set; }
/// Total UDP packets sent.
[TsField("connection_packets_sent_total")]
public long PacketsSent { get; protected set; }
/// Total UDP packets received.
[TsField("connection_packets_received_total")]
public long PacketsReceived { get; protected set; }
/// Total bytes sent.
[TsField("connection_bytes_sent_total")]
public long BytesSent { get; protected set; }
/// Total bytes received.
[TsField("connection_bytes_received_total")]
public long BytesReceived { get; protected set; }
/// Average outgoing bandwidth in bytes/s over the last second.
[TsField("connection_bandwidth_sent_last_second_total")]
public int LastSecondAvgOutgoingBandwidth { get; protected set; }
/// Average outgoing bandwidth in bytes/s over the last minute.
[TsField("connection_bandwidth_sent_last_minute_total")]
public int LastMinuteAvgOutgoingBandwidth { get; protected set; }
/// Average incoming bandwidth in bytes/s over the last second.
[TsField("connection_bandwidth_received_last_second_total")]
public int LastSecondAvgIncomingBandwidth { get; protected set; }
/// Average incoming bandwidth in bytes/s over the last minute.
[TsField("connection_bandwidth_received_last_minute_total")]
public int LastMinuteAvgIncomingBandwidth { get; protected set; }
/// Duration since the server was started.
[TsField("connection_connected_time")]
public TimeSpan TimeConnected { get; protected set; }
/// Total packet loss percentage.
[TsField("connection_packetloss_total")]
public float Packetloss { get; protected set; }
/// Average round-trip ping in milliseconds.
[TsField("connection_ping")]
public float Ping { get; protected set; }
/// Total voice packets sent.
[TsField("connection_packets_sent_speech")]
public long SpeechPacketsSent { get; protected set; }
/// Total bytes sent as voice traffic.
[TsField("connection_bytes_sent_speech")]
public long SpeechBytesSent { get; protected set; }
/// Total voice packets received.
[TsField("connection_packets_received_speech")]
public long SpeechPacketsReceived { get; protected set; }
/// Total bytes received as voice traffic.
[TsField("connection_bytes_received_speech")]
public long SpeechBytesReceived { get; protected set; }
/// Total keep-alive packets sent.
[TsField("connection_packets_sent_keepalive")]
public long KeepAlivePacketsSent { get; protected set; }
/// Total bytes sent as keep-alive traffic.
[TsField("connection_bytes_sent_keepalive")]
public long KeepAliveBytesSent { get; protected set; }
/// Total keep-alive packets received.
[TsField("connection_packets_received_keepalive")]
public long KeepAlivePacketsReceived { get; protected set; }
/// Total bytes received as keep-alive traffic.
[TsField("connection_bytes_received_keepalive")]
public long KeepAliveBytesReceived { get; protected set; }
/// Total control packets sent.
[TsField("connection_packets_sent_control")]
public long ControlPacketsSent { get; protected set; }
/// Total bytes sent as control traffic.
[TsField("connection_bytes_sent_control")]
public long ControlBytesSent { get; protected set; }
/// Total control packets received.
[TsField("connection_packets_received_control")]
public long ControlPacketsReceived { get; protected set; }
/// Total bytes received as control traffic.
[TsField("connection_bytes_received_control")]
public long ControlBytesReceived { get; protected set; }
internal ConnectionInfo(TsDataEntry data) : base(data) { }
///
public override string ToString() => $"Connected: {TimeConnected}, Ping: {Ping} ({Packetloss:0.00} %)";
///
public override int GetHashCode() => TimeConnected.GetHashCode();
///
public override bool Equals(object obj) => obj is ConnectionInfo && (obj as ConnectionInfo).TimeConnected.Equals(TimeConnected);
}
}