mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Network: Each interface now keeps its own statistics
this allows more detailed analysis.
This commit is contained in:
@ -77,6 +77,11 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
/** @var SleeperNotifier */
|
||||
private $sleeper;
|
||||
|
||||
/** @var int */
|
||||
private $sendBytes = 0;
|
||||
/** @var int */
|
||||
private $receiveBytes = 0;
|
||||
|
||||
public function __construct(Server $server){
|
||||
$this->server = $server;
|
||||
|
||||
@ -221,7 +226,8 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
public function handleOption(string $option, string $value) : void{
|
||||
if($option === "bandwidth"){
|
||||
$v = unserialize($value);
|
||||
$this->network->addStatistics($v["up"], $v["down"]);
|
||||
$this->sendBytes = $v["up"];
|
||||
$this->receiveBytes = $v["down"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,4 +249,16 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
$this->sessions[$sessionId]->updatePing($pingMS);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBytesSent() : int{
|
||||
return $this->sendBytes;
|
||||
}
|
||||
|
||||
public function getBytesReceived() : int{
|
||||
return $this->receiveBytes;
|
||||
}
|
||||
|
||||
public function resetTrafficStats() : void{
|
||||
$this->sendBytes = $this->receiveBytes = 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user