1
0
Fork 0

add ping data

master 1.0.1
Anton Smirnov 9 years ago
parent f421091cf0
commit b8a9ec4b2b

@ -40,6 +40,7 @@ class ServerQuery
private $challenge_packed;
private $retries;
private $max_retries;
private $ping;
private $socket;
@ -86,6 +87,8 @@ class ServerQuery
private function handshake($bypass_retries = false)
{
$start = microtime(true);
$this->sendPacket(self::PACKET_TYPE_CHALLENGE);
try {
@ -103,6 +106,8 @@ class ServerQuery
}
}
$this->ping = round((microtime(true)-$start)*1000);
$this->challenge = intval(substr($buff, 0, -1));
$this->challenge_packed = pack('N', $this->challenge);
}
@ -142,6 +147,8 @@ class ServerQuery
$data['numplayers'] = intval($data['numplayers']);
$data['maxplayers'] = intval($data['maxplayers']);
$data['ping'] = $this->ping;
return $data;
}
@ -206,6 +213,8 @@ class ServerQuery
list($data['software'], $data['plugins']) = $this->parsePlugins($data['raw_plugins']);
$data['ping'] = $this->ping;
return $data;
}