protected function attemptUpgrade(NetworkConnectionInterface $conn)
{
$request = $conn->WebSocket->request;
if (!$this->wsDriver->checkVersion($request)) {
return $this->close($conn);
}
$conn->WebSocket->version = $this->wsDriver->getVersion($request);
try {
$response = $conn->WebSocket->version->wsHandshake($request);
} catch (Error $ex) {
return;
} catch (Exception $ex) {
return;
}
$conn->send($response);
if ($response->getStatusCode() !== 101) {
return $conn->close();
}
$upgraded = $conn->WebSocket->version->wsUpgrade($conn, $this->wsServer);
$this->connCollection->attach($conn, $upgraded);
$upgraded->WebSocket->established = true;
$this->wsServer->handleConnect($upgraded);
}