/**
  * {@inheritdoc}
  */
 public function start(ServerContextInterface $context, RequestHandlerInterface $requestHandler)
 {
     $this->loop = Factory::create();
     $this->socketServer = new SocketServer($this->loop);
     $this->httpServer = new HttpServer($this->socketServer);
     $this->httpServer->on('request', $this->createRequestHandler($requestHandler));
     $this->socketServer->listen($context->getListenPort(), $context->getListenAddress());
     $this->loop->run();
 }
Beispiel #2
0
 /**
  * Run react.
  *
  * @param int    $port
  * @param string $host
  */
 public function run($port, $host)
 {
     $request_handler = function (Request $request, Response $response) {
         echo $request->getMethod() . ' ' . $request->getPath() . PHP_EOL;
         $sf_request = $this->request_bridge->convertRequest($request);
         $sf_response = $this->app->handle($sf_request);
         $this->app->terminate($sf_request, $sf_response);
         $this->response_bridge->send($response, $sf_response);
     };
     $this->http->on('request', $request_handler);
     $this->socket->listen($port, $host);
     $this->loop->run();
 }