How To Show Ping From Player To Player

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
-Fantastic-
Posts: 9
Joined: 01 May 2010, 00:34
Location: itsNONEOFURBISSOKAY AV

How To Show Ping From Player To Player

Post by -Fantastic- »

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();
Stick Figure Fighting Maker

Dennis Los Tejada
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

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.
Lapo
--
gotoAndPlay()
...addicted to flash games
-Fantastic-
Posts: 9
Joined: 01 May 2010, 00:34
Location: itsNONEOFURBISSOKAY AV

Post by -Fantastic- »

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.
How Would you Use roundTripBench To Show the ping?

I try'd using roundTripBench but, I fail'd using it.
Stick Figure Fighting Maker

Dennis Los Tejada
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

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);
};
linfour
Posts: 1
Joined: 12 May 2010, 13:06

Post by linfour »

I entered a room but still can't receive the elapsed number. What may be the problem? :?
Post Reply