mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 03:51:37 +00:00
Updated RakLib to pmmp/RakLib@6fbccdb6a7
This commit is contained in:
@@ -43,6 +43,7 @@ use raklib\utils\InternetAddress;
|
||||
use function addcslashes;
|
||||
use function bin2hex;
|
||||
use function implode;
|
||||
use function microtime;
|
||||
use function mt_rand;
|
||||
use function random_bytes;
|
||||
use function rtrim;
|
||||
@@ -82,9 +83,13 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
/** @var SleeperNotifier */
|
||||
private $sleeper;
|
||||
|
||||
/** @var float */
|
||||
private $lastBandwidthReport;
|
||||
|
||||
public function __construct(Server $server){
|
||||
$this->server = $server;
|
||||
$this->rakServerId = mt_rand(0, PHP_INT_MAX);
|
||||
$this->lastBandwidthReport = microtime(true);
|
||||
|
||||
$this->sleeper = new SleeperNotifier();
|
||||
|
||||
@@ -221,7 +226,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
public function setName(string $name) : void{
|
||||
$info = $this->server->getQueryInformation();
|
||||
|
||||
$this->interface->setOption("name", implode(";",
|
||||
$this->interface->setName(implode(";",
|
||||
[
|
||||
"MCPE",
|
||||
rtrim(addcslashes($name, ";"), '\\'),
|
||||
@@ -237,18 +242,18 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
}
|
||||
|
||||
public function setPortCheck(bool $name) : void{
|
||||
$this->interface->setOption("portChecking", $name);
|
||||
$this->interface->setPortCheck($name);
|
||||
}
|
||||
|
||||
public function setPacketLimit(int $limit) : void{
|
||||
$this->interface->setOption("packetLimit", $limit);
|
||||
$this->interface->setPacketsPerTickLimit($limit);
|
||||
}
|
||||
|
||||
public function handleOption(string $option, string $value) : void{
|
||||
if($option === "bandwidth"){
|
||||
$v = unserialize($value);
|
||||
$this->network->addStatistics($v["up"], $v["down"]);
|
||||
}
|
||||
public function handleBandwidthStats(int $bytesSentDiff, int $bytesReceivedDiff) : void{
|
||||
$now = microtime(true);
|
||||
$diff = $now - $this->lastBandwidthReport;
|
||||
$this->lastBandwidthReport = $now;
|
||||
$this->network->addStatistics($bytesSentDiff / $diff, $bytesReceivedDiff / $diff);
|
||||
}
|
||||
|
||||
public function putPacket(int $sessionId, string $payload, bool $immediate = true) : void{
|
||||
|
Reference in New Issue
Block a user