diff --git a/Shared/Network/Abstract/IConnection.cs b/Shared/Network/Abstract/IConnection.cs index 7bfccc1..a477434 100644 --- a/Shared/Network/Abstract/IConnection.cs +++ b/Shared/Network/Abstract/IConnection.cs @@ -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; } } diff --git a/Shared/Network/LiteNetLib/LiteNetLibClientConnection.cs b/Shared/Network/LiteNetLib/LiteNetLibClientConnection.cs index b1e4763..add84ad 100644 --- a/Shared/Network/LiteNetLib/LiteNetLibClientConnection.cs +++ b/Shared/Network/LiteNetLib/LiteNetLibClientConnection.cs @@ -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})"; } diff --git a/Shared/Network/LiteNetLib/LiteNetLibServerConnection.cs b/Shared/Network/LiteNetLib/LiteNetLibServerConnection.cs index 7596a85..783698f 100644 --- a/Shared/Network/LiteNetLib/LiteNetLibServerConnection.cs +++ b/Shared/Network/LiteNetLib/LiteNetLibServerConnection.cs @@ -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})"; }