@@ -36,6 +36,7 @@ public ushort NextTwoWayPingData() {
3636 ushort SetTwoWayPing ( int i , ushort prev ) {
3737 Entries [ i ] . Data = ( ushort ) ( prev + 1 ) ;
3838 Entries [ i ] . TimeSent = DateTime . UtcNow ;
39+ Entries [ i ] . TimeReceived = default ( DateTime ) ;
3940 return ( ushort ) ( prev + 1 ) ;
4041 }
4142
@@ -48,42 +49,42 @@ public void Update(ushort data) {
4849 }
4950
5051
51- /// <summary> Gets best ping in milliseconds, or 0 if no ping measures. </summary>
52- public double BestPingMilliseconds ( ) {
52+ /// <summary> Gets lowest ( best) ping in milliseconds, or 0 if no ping measures. </summary>
53+ public int LowestPingMilliseconds ( ) {
5354 double totalMs = 100000000 ;
5455 foreach ( PingEntry ping in Entries ) {
5556 if ( ping . TimeSent . Ticks == 0 || ping . TimeReceived . Ticks == 0 ) continue ;
5657 totalMs = Math . Min ( totalMs , ping . Latency ) ;
5758 }
58- return totalMs ;
59+ return ( int ) totalMs ;
5960 }
6061
6162 /// <summary> Gets average ping in milliseconds, or 0 if no ping measures. </summary>
62- public double AveragePingMilliseconds ( ) {
63+ public int AveragePingMilliseconds ( ) {
6364 double totalMs = 0 ;
6465 int measures = 0 ;
6566 foreach ( PingEntry ping in Entries ) {
6667 if ( ping . TimeSent . Ticks == 0 || ping . TimeReceived . Ticks == 0 ) continue ;
6768 totalMs += ping . Latency ; measures ++ ;
6869 }
69- return measures == 0 ? 0 : ( totalMs / measures ) ;
70+ return measures == 0 ? 0 : ( int ) ( totalMs / measures ) ;
7071 }
7172
7273 /// <summary> Gets worst ping in milliseconds, or 0 if no ping measures. </summary>
73- public double WorstPingMilliseconds ( ) {
74+ public double HighestPingMilliseconds ( ) {
7475 double totalMs = 0 ;
7576 foreach ( PingEntry ping in Entries ) {
7677 if ( ping . TimeSent . Ticks == 0 || ping . TimeReceived . Ticks == 0 ) continue ;
7778 totalMs = Math . Max ( totalMs , ping . Latency ) ;
7879 }
79- return totalMs ;
80+ return ( int ) totalMs ;
8081 }
8182
8283 public string Format ( ) {
8384 return String . Format ( "Lowest ping {0}ms, average {1}ms, highest {2}ms" ,
84- ( int ) BestPingMilliseconds ( ) ,
85- ( int ) AveragePingMilliseconds ( ) ,
86- ( int ) WorstPingMilliseconds ( ) ) ;
85+ LowestPingMilliseconds ( ) ,
86+ AveragePingMilliseconds ( ) ,
87+ HighestPingMilliseconds ( ) ) ;
8788 }
8889 }
8990}
0 commit comments