private function doClose(Rfc6455Client $client, int $code, string $reason) : \Generator
{
// Only proceed if we haven't already begun the close handshake elsewhere
if ($client->closedAt) {
return;
}
$this->closeTimeouts[$client->id] = $this->now + $this->closePeriod;
$promise = $this->sendCloseFrame($client, $code, $reason);
yield from $this->tryAppOnClose($client->id, $code, $reason);
return $promise;
// Don't unload the client here, it will be unloaded upon timeout
}