当前位置: 首页>>代码示例>>PHP>>正文


PHP LoopInterface::run方法代码示例

本文整理汇总了PHP中React\EventLoop\LoopInterface::run方法的典型用法代码示例。如果您正苦于以下问题:PHP LoopInterface::run方法的具体用法?PHP LoopInterface::run怎么用?PHP LoopInterface::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在React\EventLoop\LoopInterface的用法示例。


在下文中一共展示了LoopInterface::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run main bot process
  */
 public function run()
 {
     $this->prepareOnMessage();
     $this->preparePeriodicCommands();
     $this->connect();
     $this->loop->run();
 }
开发者ID:valinurovam,项目名称:slackbot,代码行数:10,代码来源:Bot.php

示例2: getStatus

 public function getStatus(callable $callback)
 {
     $this->request('status', [], function ($result) use($callback) {
         $callback(json_decode($result, true));
     });
     $this->loop->run();
 }
开发者ID:php-pm,项目名称:php-pm,代码行数:7,代码来源:Client.php

示例3: start

 /**
  * Start the HTTP Server
  */
 public function start()
 {
     $this->httpServer->on('request', [$this, 'handleRequest']);
     $this->logger->info("Server is listening at " . $this->configuration['listen']['host'] . ":" . $this->configuration['listen']['port']);
     $this->socketServer->listen($this->configuration['listen']['port'], $this->configuration['listen']['host']);
     $this->eventLoop->run();
 }
开发者ID:thinframe,项目名称:server,代码行数:10,代码来源:Server.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->client->getUsers()->then(function ($users) use($output) {
         $this->importUsers($users, $output);
     });
     $this->loop->run();
 }
开发者ID:vincecore,项目名称:sharemonkey-bundle,代码行数:7,代码来源:ImportSlackUsersCommand.php

示例5: run

 /**
  * Run the application by entering the event loop
  * @throws \RuntimeException If a loop was not previously specified
  */
 public function run()
 {
     if (null === $this->loop) {
         throw new \RuntimeException("A React Loop was not provided during instantiation");
     }
     // @codeCoverageIgnoreStart
     $this->loop->run();
     // @codeCoverageIgnoreEnd
 }
开发者ID:hugohenrique,项目名称:Ratchet,代码行数:13,代码来源:IoServer.php

示例6: start

 /**
  * {@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();
 }
开发者ID:syrma-php,项目名称:web-container,代码行数:12,代码来源:ReactServer.php

示例7: run

 /**
  * @param array $options
  * @param array $arguments
  * @return mixed
  */
 public function run(array $options, array $arguments)
 {
     $port = isset($arguments[0]) ? $arguments[0] : "8001";
     $host = isset($arguments[1]) ? $arguments[1] : "0.0.0.0";
     /** @var \Castle23\Http\Server $server */
     $server = $this->container->getInstanceOf(Server::class);
     $this->socket->listen($port, $host);
     $this->loop->run();
 }
开发者ID:ppetermann,项目名称:castle23,代码行数:14,代码来源:Serve.php

示例8: run

 public function run()
 {
     $this->processes = $this->stdout = $this->runtimes = $this->results = [];
     $this->process_id = 0;
     while (count($this->processes) < $this->cpus) {
         $this->queueProcess();
     }
     $this->loop->run();
     $this->calculateResults();
 }
开发者ID:elazar,项目名称:spl-benchmarks,代码行数:10,代码来源:BenchmarkRunner.php

示例9: start

 /**
  * Starts the websocket server
  *
  * @return void
  */
 public function start()
 {
     $this->__loop = LoopFactory::create();
     if ($this->__loop instanceof \React\EventLoop\StreamSelectLoop) {
         $this->out('<warning>Your configuration doesn\'t seem to support \'ext-libevent\'. It is highly reccomended that you install and configure it as it provides significant performance gains over stream select!</warning>');
     }
     $socket = new Reactor($this->__loop);
     $socket->listen(Configure::read('Ratchet.Connection.websocket.port'), Configure::read('Ratchet.Connection.websocket.address'));
     $this->__ioServer = new IoServer(new HttpServer(new WsServer(new SessionProvider(new WampServer(new CakeWampAppServer($this, $this->__loop, CakeEventManager::instance(), $this->params['verbose'])), new CakeWampSessionHandler(), [], new PhpSerializeHandler()))), $socket, $this->__loop);
     $this->__loop->run();
 }
开发者ID:schnauss,项目名称:Ratchet,代码行数:16,代码来源:WebsocketShell.php

示例10: start

 public function start()
 {
     $this->loop = \WyriHaximus\Ratchet\loopResolver();
     $router = new Router($this->loop);
     $router->addInternalClient(new InternalClient('first', $this->loop));
     $router->addTransportProvider(new RatchetTransportProvider(Configure::read('WyriHaximus.Ratchet.Connection.Websocket.address'), Configure::read('WyriHaximus.Ratchet.Connection.Websocket.port')));
     //$router->getRealmManager()->setDefaultAuthorizationManager(new AllPermissiveAuthorizationManager());
     EventManager::instance()->dispatch(WebsocketStartEvent::create($this->loop));
     $router->start(false);
     $this->loop->run();
 }
开发者ID:mrduongnv,项目名称:Ratchet,代码行数:11,代码来源:WebsocketShell.php

示例11: run

 /**
  * Runs the message server on the given port.
  *
  * @param string  $consumer Command to execute when a message arrives
  * @param integer $port     Port to run the server on
  *
  * @return void
  */
 public function run($consumer, $port, $callback = null)
 {
     // @codeCoverageIgnoreStart
     $this->socket->on('connection', function (ConnectionInterface $conn) use($consumer, $callback) {
         $conn->on('data', function ($data) use($conn, $consumer, $callback) {
             $this->handleData(trim($data), $consumer, $conn, $callback);
         });
     });
     // @codeCoverageIgnoreEnd
     $this->socket->listen($port);
     $this->loop->run();
 }
开发者ID:braincrafted,项目名称:mq,代码行数:20,代码来源:Server.php

示例12: start

 /**
  * Start the websocket server
  */
 public function start()
 {
     $this->__loop = Factory::create();
     $pusher = new CakeWampAppServer();
     $context = new Context($this->__loop);
     $pull = $context->getSocket(ZMQ::SOCKET_PULL);
     $pull->bind("tcp://" . Configure::read('CakeRatchet.ZMQServer.host') . ":" . Configure::read('CakeRatchet.ZMQServer.port'));
     $pull->on('message', array($pusher, 'onBlogEntry'));
     $webSock = new Server($this->__loop);
     $webSock->listen(Configure::read('CakeRatchet.Server.port'), Configure::read('CakeRatchet.Server.host'));
     $this->__ioServer = new IoServer(new HttpServer(new WsServer(new WampServer($pusher))), $webSock);
     $this->__loop->run();
 }
开发者ID:rapsspider,项目名称:cake_ratchet,代码行数:16,代码来源:RatchetShell.php

示例13: run

 /**
  * 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();
 }
开发者ID:KEIII,项目名称:react-silex,代码行数:19,代码来源:ReactServer.php

示例14: itReadsToEnd

 /**
  * @test
  */
 public function itReadsToEnd()
 {
     $handle = $this->wrap(fopen('php://temp', 'w+'));
     fwrite($handle, 'data');
     async_stream_register_write($handle, function ($handle) {
         fseek($handle, 0);
         $this->assertFalse(feof($handle));
         fread($handle, 4);
         $this->assertTrue(feof($handle));
         fclose($handle);
     });
     $this->loop->run();
 }
开发者ID:krinfreschi,项目名称:async-streams,代码行数:16,代码来源:AsyncStreamWrapperTest.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $client = $this->client;
     $client->on('message', function (Payload $payload) use($output) {
         $this->onMessage($payload, $output);
     });
     $client->on('reaction_added', function (Payload $payload) use($client, $output) {
         $this->onReaction($payload, $output);
     });
     $client->connect()->then(function () use($client, $output) {
         $output->writeln('<info>Connected</info>');
     });
     $this->loop->run();
 }
开发者ID:vincecore,项目名称:sharemonkey-bundle,代码行数:14,代码来源:ListenCommand.php


注:本文中的React\EventLoop\LoopInterface::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。