Dispatched when a response to the RoundTripBench()()() request is received.
The "roundtrip time" represents the number of milliseconds that it takes to a message to go from the client to the server and back to the client.
A good way to measure the network lag is to send continuos requests (every 3 or 5 seconds) and then calculate the average roundtrip time on a fixed number of responses (i.e. the last 10 measurements).
The "roundtrip time" represents the number of milliseconds that it takes to a message to go from the client to the server and back to the client.
A good way to measure the network lag is to send continuos requests (every 3 or 5 seconds) and then calculate the average roundtrip time on a fixed number of responses (i.e. the last 10 measurements).


- elapsed (Int32)
- the roundtrip time.

Version:
SmartFoxServer Basic / Pro

The following example shows how to check the average network lag time.
CopyC#

SFSEvent.onRoundTripResponse += OnRoundTripResponse; int totalPingTime = 0; int pingCount = 0; smartFox.RoundTripBench(); // TODO: this method must be called repeatedly every 3-5 seconds to have a significant average value public void OnRoundTripResponse(int elapsed) { int time = elapsed; // We assume that it takes the same time to the ping message to go from the client to the server // and from the server back to the client, so we divide the elapsed time by 2. totalPingTime += time / 2; pingCount++; int avg = Math.Round(totalPingTime / pingCount); Debug.WriteLine("Average lag: " + avg + " milliseconds"); }
