private function upgradeClient(ClientUpgradeException $upgrade)
    {
        $oldClient = $upgrade->getOldClient();

        if (!isset($oldClient->socket, $this->nodes[(int)$oldClient->socket])) {
            $this->logger->emergency("Client $oldClient not found during upgrade");
            throw new ServerException('Tried to upgrade non existing client!');
        }

        $this->nodes[(int)$oldClient->socket] = $upgrade->getNewClient();
    }