refactor: connection ping & round trip in milliseconds properties added

This commit is contained in:
Syntriax 2025-07-06 20:09:25 +03:00
parent a76905f31e
commit 22f96458a6
3 changed files with 13 additions and 1 deletions

View File

@ -3,6 +3,10 @@ namespace Syntriax.Engine.Network;
public interface IConnection
{
string Id { get; }
float Ping { get; }
float RoundTrip { get; }
int PingMs { get; }
int RoundTripMs { get; }
}

View File

@ -5,8 +5,12 @@ namespace Syntriax.Engine.Network;
public record class LiteNetLibClientConnection(NetPeer NetPeer) : IConnection
{
public string Id { get; } = NetPeer.Id.ToString();
public float Ping => NetPeer.Ping * .001f;
public float RoundTrip => NetPeer.RoundTripTime * .001f;
public int PingMs => NetPeer.Ping;
public int RoundTripMs => NetPeer.RoundTripTime;
public override string ToString() => $"Connection({Id})";
}

View File

@ -4,9 +4,13 @@ namespace Syntriax.Engine.Network;
public record class LiteNetLibServerConnection(NetPeer NetPeer) : IConnection
{
public string Id { get; } = NetPeer.RemoteId.ToString();
public string Id => NetPeer.RemoteId.ToString();
public float Ping => NetPeer.Ping * .001f;
public float RoundTrip => NetPeer.RoundTripTime * .001f;
public int PingMs => NetPeer.Ping;
public int RoundTripMs => NetPeer.RoundTripTime;
public override string ToString() => $"Connection({Id})";
}