// This is almost a direct rip from Mirror's NetworkTime.OnClientPong(...), but at least I understand how it works. /// <summary> /// Finishes an offset update. /// </summary> /// <param name="message">The times sent by the server, including the original send time.</param> public void ProcessPong(Timestamped <PingMessage> message) { var offset = ProcessPong(message, out var rtt, out var offsetBounds); _offsetBounds = _offsetBounds.Clamp(offsetBounds); if (!_offsetBounds.IsWithin(_offsetAverage.Value)) // Average does not exist or is out of known bounds. { _offsetAverage.Reset(_offsetBounds.Clamp(offset)); } else if (_offsetBounds.IsWithin(offset)) // New offset is within bounds. { _offsetAverage.Push(offset); } _rttAverage.Push(rtt); Received?.Invoke(offset, rtt); }