Is there a function that will display latency?

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

Post Reply
intomo
Posts: 51
Joined: 22 Nov 2010, 21:21
Location: Los Angeles

Is there a function that will display latency?

Post by intomo »

Is there a function that will display latency?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Is there a function that will display latency?

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply