How to Check the Round-trip Time between the Server¶
Some online games are sensitive to the network latency. Many games use a metric called round-trip time (or ping), that indicates some overall communication delay between the game client and the server.
Strix collects statistics to calculate this metric during its network operations
and exposes it to scripts
through RTT
property of SyncTimeClient class,
which in turn is available through syncTimeClient
properties of
RoomSession
.
Each session may show a different RTT. In Strix, majority of the in-game communication is to/from the room server, and use of currently-connected RoomSession is appropriate to know the effective RTT value.
Example:
public Text RttText;
void Update()
{
if (RttText != null)
{
RttText.text = StrixNetwork.instance.roomSession.syncTimeClient.RTT.ToString();
}
}
Note
RTT property is of type int, and its value is in milliseconds (ms).