/**
* {@inheritdoc}
*/
public function writeResponse(Socket $socket, Response $response, Request $request = null, float $timeout = 0) : \Generator
{
$written = (yield from parent::writeResponse($socket, $response, $request, $timeout));
if ($response instanceof WebSocketResponse) {
$application = $response->getApplication();
$connection = $response->getConnection();
$response = $response->getMessage();
yield from $this->onConnection($application, $connection, $response, $request);
}
return $written;
}