/** * Disconnect client * * @param \WebSocketServer\Socket\Client $client The client to disconnect * * @throws \OutOfRangeException When passed client does not belong to this server */ public function removeClient(Client $client) { if ($client->getServer() !== $this) { throw new \OutOfRangeException('Client does not belong to this server'); } if ($client->isConnected()) { $client->disconnect(); } $id = $client->getId(); if (isset($this->clients[$id])) { unset($this->clients[$id], $this->sockets[$id]); $this->trigger('clientremove', $this, $client); } }