mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Network: Each interface now keeps its own statistics
this allows more detailed analysis.
This commit is contained in:
@ -49,9 +49,6 @@ class Network{
|
||||
/** @var int[] */
|
||||
private $bannedIps = [];
|
||||
|
||||
private $upload = 0;
|
||||
private $download = 0;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
@ -67,22 +64,26 @@ class Network{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function addStatistics(float $upload, float $download) : void{
|
||||
$this->upload += $upload;
|
||||
$this->download += $download;
|
||||
}
|
||||
|
||||
public function getUpload() : float{
|
||||
return $this->upload;
|
||||
$result = 0;
|
||||
foreach($this->advancedInterfaces as $interface){
|
||||
$result += $interface->getBytesSent();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDownload() : float{
|
||||
return $this->download;
|
||||
$result = 0;
|
||||
foreach($this->advancedInterfaces as $interface){
|
||||
$result += $interface->getBytesReceived();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function resetStatistics() : void{
|
||||
$this->upload = 0;
|
||||
$this->download = 0;
|
||||
foreach($this->advancedInterfaces as $interface){
|
||||
$interface->resetTrafficStats();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user