refactor: connection ping & round trip in milliseconds properties added
This commit is contained in:
parent
a76905f31e
commit
22f96458a6
@ -3,6 +3,10 @@ namespace Syntriax.Engine.Network;
|
|||||||
public interface IConnection
|
public interface IConnection
|
||||||
{
|
{
|
||||||
string Id { get; }
|
string Id { get; }
|
||||||
|
|
||||||
float Ping { get; }
|
float Ping { get; }
|
||||||
float RoundTrip { get; }
|
float RoundTrip { get; }
|
||||||
|
|
||||||
|
int PingMs { get; }
|
||||||
|
int RoundTripMs { get; }
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,12 @@ namespace Syntriax.Engine.Network;
|
|||||||
public record class LiteNetLibClientConnection(NetPeer NetPeer) : IConnection
|
public record class LiteNetLibClientConnection(NetPeer NetPeer) : IConnection
|
||||||
{
|
{
|
||||||
public string Id { get; } = NetPeer.Id.ToString();
|
public string Id { get; } = NetPeer.Id.ToString();
|
||||||
|
|
||||||
public float Ping => NetPeer.Ping * .001f;
|
public float Ping => NetPeer.Ping * .001f;
|
||||||
public float RoundTrip => NetPeer.RoundTripTime * .001f;
|
public float RoundTrip => NetPeer.RoundTripTime * .001f;
|
||||||
|
|
||||||
|
public int PingMs => NetPeer.Ping;
|
||||||
|
public int RoundTripMs => NetPeer.RoundTripTime;
|
||||||
|
|
||||||
public override string ToString() => $"Connection({Id})";
|
public override string ToString() => $"Connection({Id})";
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,13 @@ namespace Syntriax.Engine.Network;
|
|||||||
|
|
||||||
public record class LiteNetLibServerConnection(NetPeer NetPeer) : IConnection
|
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 Ping => NetPeer.Ping * .001f;
|
||||||
public float RoundTrip => NetPeer.RoundTripTime * .001f;
|
public float RoundTrip => NetPeer.RoundTripTime * .001f;
|
||||||
|
|
||||||
|
public int PingMs => NetPeer.Ping;
|
||||||
|
public int RoundTripMs => NetPeer.RoundTripTime;
|
||||||
|
|
||||||
public override string ToString() => $"Connection({Id})";
|
public override string ToString() => $"Connection({Id})";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user