private function timeout()
{
$this->now = $now = time();
foreach ($this->closeTimeouts as $clientId => $expiryTime) {
if ($expiryTime < $now) {
$this->unloadClient($this->clients[$clientId]);
unset($this->closeTimeouts[$clientId]);
} else {
break;
}
}
foreach ($this->heartbeatTimeouts as $clientId => $expiryTime) {
if ($expiryTime < $now) {
$client = $this->clients[$clientId];
unset($this->heartbeatTimeouts[$clientId]);
$this->heartbeatTimeouts[$clientId] = $now + $this->heartbeatPeriod;
$this->sendHeartbeatPing($client);
} else {
break;
}
}
foreach ($this->lowCapacityClients as $id => $client) {
$client->capacity += $this->maxBytesPerMinute / 60;
if ($client->capacity > $this->maxBytesPerMinute) {
unset($this->lowCapacityClients[$id]);
}
if ($client->capacity > 8192 && !isset($this->highFramesPerSecondClients[$id])) {
\Amp\enable($client->readWatcher);
}
}
foreach ($this->highFramesPerSecondClients as $id => $client) {
$client->framesLastSecond -= $this->maxFramesPerSecond;
if ($client->framesLastSecond < $this->maxFramesPerSecond) {
unset($this->highFramesPerSecondClients[$id]);
if ($client->capacity > 8192) {
\Amp\enable($client->readWatcher);
}
}
}
}