Read lagMonitor value of session or user on server?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
SmartfoxEnjoyer
Posts: 93
Joined: 13 Dec 2023, 20:39

Read lagMonitor value of session or user on server?

Post by SmartfoxEnjoyer »

I really need the ping/latency time of each user for my game, its easy on the client and this value sems to be calculated by the server and then sent to the user via a event, can we please get access to this same value on the server per user or session?

It would be super useful to have user.getLastLatency(); or session.getLastPing() or something similar.
It doesnt even have to be the same value as the client-side lagMonitor, just anything that approaches the actual ping time of the user.

My workaround is to send a message to every client every n secs and have the client reply immediately with an empty message to log the time, but this is 1) insecure since a client can potentially delay their response and thus make the server think their latency isa much higher than it really is and 2) its an extra compuational step and bandwith that would be unnecessary if we had a builtin way...

Thanks and cheers!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Read lagMonitor value of session or user on server?

Post by Lapo »

What you're doing is correct.

The value provided by the Monitor is calculated at the client side: by sending a "ping" request to the server and waiting for the respective "pong" from the server. It's also called the RTT (round trip time).

If you need a similar value from the server side you can invert the process (send ping from server, wait for pong).
Keep in mind: this is the latency it takes for a packet to go back and forth. If you just need the server->client latency it's probably best to divide the RTT by two. It won't be the exact value but a good estimate.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply