public function reapClient($watcherId, InternalRequest $ireq)
{
$client = new Rfc6455Client();
$client->capacity = $this->maxBytesPerMinute;
$client->connectedAt = $this->now;
$socket = $ireq->client->socket;
$client->id = (int) $socket;
$client->socket = $socket;
$client->writeBuffer = $ireq->client->writeBuffer;
$client->serverRefClearer = ($ireq->client->exporter)($ireq->client);
$client->parser = $this->parser([$this, "onParse"], $options = ["cb_data" => $client, "max_msg_size" => $this->maxMsgSize, "max_frame_size" => $this->maxFrameSize, "validate_utf8" => $this->validateUtf8, "text_only" => $this->textOnly, "threshold" => $this->autoFrameSize]);
$client->readWatcher = \Amp\onReadable($socket, [$this, "onReadable"], $options = ["enable" => true, "cb_data" => $client]);
$client->writeWatcher = \Amp\onWritable($socket, [$this, "onWritable"], $options = ["enable" => $client->writeBuffer != "", "cb_data" => $client]);
$this->clients[$client->id] = $client;
$this->heartbeatTimeouts[$client->id] = $this->now + $this->heartbeatPeriod;
resolve($this->tryAppOnOpen($client->id, $ireq->locals["aerys.websocket"]));
return $client;
}