Is there a function that will display latency?

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

Moderators: Lapo, Bax

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

Is there a function that will display latency?

Postby intomo » 17 Nov 2021, 19:53

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

Re: Is there a function that will display latency?

Postby Lapo » 18 Nov 2021, 09:14

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

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 14 guests