Mirror Networking
Mirror.NetworkTime Class Reference

Synchronizes server time to clients. More...

Static Public Member Functions

static void ResetStatics ()
 

Static Public Attributes

static float PingFrequency = 2.0f
 Ping message frequency, used to calculate network time and RTT More...
 
static int PingWindowSize = 10
 Average out the last few results from Ping More...
 

Properties

static double localTime [get]
 
static double time [get, set]
 The time in seconds since the server started. More...
 
static double timeVariance [get]
 Time measurement variance. The higher, the less accurate the time is. More...
 
static double timeStandardDeviation [get]
 Time standard deviation. The highe, the less accurate the time is. More...
 
static double offset [get]
 Clock difference in seconds between the client and the server. Always 0 on server. More...
 
static double rtt [get]
 Round trip time (in seconds) that it takes a message to go client->server->client. More...
 
static double rttVariance [get]
 Round trip time variance. The higher, the less accurate the rtt is. More...
 
static double rttStandardDeviation [get]
 Round trip time standard deviation. The higher, the less accurate the rtt is. More...
 

Detailed Description

Synchronizes server time to clients.

Definition at line 11 of file NetworkTime.cs.

Member Function Documentation

◆ ResetStatics()

static void Mirror.NetworkTime.ResetStatics ( )
static

Definition at line 86 of file NetworkTime.cs.

87 {
88 PingFrequency = 2.0f;
89 PingWindowSize = 10;
90 lastPingTime = 0;
91 _rtt = new ExponentialMovingAverage(PingWindowSize);
92 _offset = new ExponentialMovingAverage(PingWindowSize);
93 offsetMin = double.MinValue;
94 offsetMax = double.MaxValue;
95#if !UNITY_2020_3_OR_NEWER
96 stopwatch.Restart();
97#endif
98 }
static int PingWindowSize
Average out the last few results from Ping
Definition: NetworkTime.cs:17
static float PingFrequency
Ping message frequency, used to calculate network time and RTT
Definition: NetworkTime.cs:14

Member Data Documentation

◆ PingFrequency

float Mirror.NetworkTime.PingFrequency = 2.0f
static

Ping message frequency, used to calculate network time and RTT

Definition at line 14 of file NetworkTime.cs.

◆ PingWindowSize

int Mirror.NetworkTime.PingWindowSize = 10
static

Average out the last few results from Ping

Definition at line 17 of file NetworkTime.cs.

Property Documentation

◆ localTime

double Mirror.NetworkTime.localTime
staticget

Definition at line 41 of file NetworkTime.cs.

◆ offset

double Mirror.NetworkTime.offset
staticget

Clock difference in seconds between the client and the server. Always 0 on server.

Definition at line 71 of file NetworkTime.cs.

◆ rtt

double Mirror.NetworkTime.rtt
staticget

Round trip time (in seconds) that it takes a message to go client->server->client.

Definition at line 74 of file NetworkTime.cs.

◆ rttStandardDeviation

double Mirror.NetworkTime.rttStandardDeviation
staticget

Round trip time standard deviation. The higher, the less accurate the rtt is.

Definition at line 82 of file NetworkTime.cs.

◆ rttVariance

double Mirror.NetworkTime.rttVariance
staticget

Round trip time variance. The higher, the less accurate the rtt is.

Definition at line 78 of file NetworkTime.cs.

◆ time

double Mirror.NetworkTime.time
staticgetset

The time in seconds since the server started.

Definition at line 56 of file NetworkTime.cs.

57 {
58 [MethodImpl(MethodImplOptions.AggressiveInlining)]
59 get => localTime - _offset.Value;
60 }

◆ timeStandardDeviation

double Mirror.NetworkTime.timeStandardDeviation
staticget

Time standard deviation. The highe, the less accurate the time is.

Definition at line 68 of file NetworkTime.cs.

◆ timeVariance

double Mirror.NetworkTime.timeVariance
staticget

Time measurement variance. The higher, the less accurate the time is.

Definition at line 64 of file NetworkTime.cs.