diff --git a/raklib/server/Session.php b/raklib/server/Session.php index d135517..dbaf1ac 100644 --- a/raklib/server/Session.php +++ b/raklib/server/Session.php @@ -111,8 +111,6 @@ public function update($time){ if(!$this->isActive and ($this->lastUpdate + 10) < $time){ $this->disconnect("timeout"); return; - }else{ - $this->lastUpdate = $time; } $this->isActive = false; @@ -299,6 +297,7 @@ protected function handleEncapsulatedPacket(EncapsulatedPacket $packet){ public function handlePacket(Packet $packet){ $this->isActive = true; + $this->lastUpdate = microtime(true); if($this->state === self::STATE_CONNECTED or $this->state === self::STATE_CONNECTING_2){ if($packet::$ID >= 0x80 and $packet::$ID <= 0x8f and $packet instanceof DataPacket){ //Data packet $packet->decode(); diff --git a/raklib/server/SessionManager.php b/raklib/server/SessionManager.php index a261620..821cabd 100644 --- a/raklib/server/SessionManager.php +++ b/raklib/server/SessionManager.php @@ -219,7 +219,7 @@ public function receiveStream(){ ++$this->ticks; if(($this->ticks & 0b1111) === 0){ - $diff = $time - $this->lastMeasure; + $diff = max(0.005, $time - $this->lastMeasure); $this->streamOption("bandwidth", serialize([ "up" => $this->sendBytes / $diff, "down" => $this->receiveBytes / $diff