Network: Each interface now keeps its own statistics

this allows more detailed analysis.
This commit is contained in:
Dylan K. Taylor
2019-04-18 19:57:40 +01:00
parent f933ce31dd
commit 7720a0534e
3 changed files with 51 additions and 13 deletions

View File

@ -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;
}
}