NetworkTime: SendPing method added.

This commit is contained in:
MrGadget 2024-02-01 06:14:22 -05:00
parent d304ada178
commit fe32a0569f

View File

@ -141,17 +141,21 @@ internal static void UpdateClient()
{
// localTime (double) instead of Time.time for accuracy over days
if (localTime >= lastPingTime + PingInterval)
{
// send raw predicted time without the offset applied yet.
// we then apply the offset to it after.
NetworkPingMessage pingMessage = new NetworkPingMessage
(
localTime,
predictedTime
);
NetworkClient.Send(pingMessage, Channels.Unreliable);
lastPingTime = localTime;
}
SendPing();
}
// Separate method so we can call it from NetworkClient directly.
internal static void SendPing()
{
// send raw predicted time without the offset applied yet.
// we then apply the offset to it after.
NetworkPingMessage pingMessage = new NetworkPingMessage
(
localTime,
predictedTime
);
NetworkClient.Send(pingMessage, Channels.Unreliable);
lastPingTime = localTime;
}
// client rtt calculation //////////////////////////////////////////////