How To Show Ping From Player To Player
anyone know how to send the delay of player to player?
I know it have to do with smartfox.roundTripBench();
How To Show Ping From Player To Player
-
-Fantastic-
- Posts: 9
- Joined: 01 May 2010, 00:34
- Location: itsNONEOFURBISSOKAY AV
How To Show Ping From Player To Player
Stick Figure Fighting Maker
Dennis Los Tejada
Dennis Los Tejada
-
-Fantastic-
- Posts: 9
- Joined: 01 May 2010, 00:34
- Location: itsNONEOFURBISSOKAY AV
How Would you Use roundTripBench To Show the ping?Lapo wrote:There is no such thing, because players are not directly connected to one another like in a Peer-to-Peer scenario.
The ping you can measure is between the client and server. See the roundTripBench() API command documentation for more.
I try'd using roundTripBench but, I fail'd using it.
Stick Figure Fighting Maker
Dennis Los Tejada
Dennis Los Tejada
First, the user must be connected and in a room. Then you can use this code to measure the ping:
Code: Select all
var totalPingTime:Number = 0;
var pingCount:Number = 0;
smartfox.roundTripBench();
smartfox.onRoundTripResponse = function(elapsed:Number):Void {
// 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 += elapsed/2;
pingCount++;
var avg:Number = Math.round(totalPingTime/pingCount);
};