loop = $loop??Loop::get(); $this->config = $config; $this->topicManager = new TopicManager(); $this->webSocketClients = new SplObjectStorage(); $this->server = $this->createHttpServer(); } /** * * * @return void */ public function listen(ServerInterface $socket): void { $this->server->listen($socket); } /** * * @return HttpServer */ private function createHttpServer(): HttpServer { return new HttpServer( $this->responseMiddleware = new ResponseMiddleware( config: $this->config ), $this->securityMiddleware = new SecurityMiddleware( config: $this->config ), $this->webSocketHandler = new WebSocketHandler( config: $this->config, webSocketClients: $this->webSocketClients, topicManager: $this->topicManager ), $this->mercureHandler = new MercureHandler( config: $this->config, topicManager: $this->topicManager ), $this->apiRequestHandler = new ApiHandler( config: $this->config, topicManager: $this->topicManager ), $this->notFoundHandler = new NotFoundHandler() ); } }