Page 1 of 1

Is there a function that will display latency?

Posted: 17 Nov 2021, 19:53
by intomo
Is there a function that will display latency?

Re: Is there a function that will display latency?

Posted: 18 Nov 2021, 09:14
by Lapo
Yes,
you can measure the client latency via the LagMonitor, built in the API.

After a successful login (i.e. in the Login event handler) you can add this line:

Code: Select all

[client enableLagMonitor:YES];
This will ping the server on a timely basis and report the average latency.
You can then query the lagMonitor like this:

Code: Select all

int avgLag = [[sfs lagMonitor] averagePingTime];
(where sfs is the client instance name)

We also have an article here with more details:
https://smartfoxserver.com/blog/the-imp ... ing-times/

Cheers