本文整理汇总了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();
}
示例2: getStatus
public function getStatus(callable $callback)
{
$this->request('status', [], function ($result) use($callback) {
$callback(json_decode($result, true));
});
$this->loop->run();
}
示例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();
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->client->getUsers()->then(function ($users) use($output) {
$this->importUsers($users, $output);
});
$this->loop->run();
}
示例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
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}