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


PHP Server\IoServer类代码示例

本文整理汇总了PHP中Ratchet\Server\IoServer的典型用法代码示例。如果您正苦于以下问题:PHP IoServer类的具体用法?PHP IoServer怎么用?PHP IoServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: start

 /**
  * Start Server
  */
 public function start()
 {
     $loop = $this->createLoop();
     $socket = $this->createSocket($loop, $this->port, $this->address);
     $ioServer = new IoServer($this->component, $socket, $loop);
     $this->logStart();
     $ioServer->run();
 }
开发者ID:bfoxwell,项目名称:votifier,代码行数:11,代码来源:Server.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $port = intval($this->option('port'));
     $this->info("Starting chat web socket server on port " . $port);
     $server = IoServer::factory(new HttpServer(new WsServer(new Chat())), 8082);
     $server->run();
 }
开发者ID:kranti52,项目名称:LaravelRatchetChatRoom,代码行数:12,代码来源:ChatServer.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $port = env('SOCKET_PORT');
     $this->info('Websocket is running on port ' . $port);
     $server = IoServer::factory(new HttpServer(new WsServer(new \App\Services\Websocket())), $port);
     $server->run();
 }
开发者ID:studentjason,项目名称:laravel-5-sockets-and-queue-async,代码行数:12,代码来源:Websocket.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $chat = $this->getContainer()->get('chat');
     $server = IoServer::factory(new HttpServer(new WsServer($chat)), 8080);
     $server->run();
     echo "Server started";
 }
开发者ID:paddya,项目名称:symfony-chat,代码行数:7,代码来源:ChatServerCommand.php

示例5: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('Starting web socket server...');
     $this->server = IoServer::factory(new HttpServer(new WsServer(new Chat())), 8080, '0.0.0.0');
     $this->info('To stop the web socket server press "Ctrl" + "C"');
     $this->server->run();
 }
开发者ID:viktory,项目名称:chat,代码行数:12,代码来源:WSCommand.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     declare (ticks=1);
     register_shutdown_function(array($this, 'stopCommand'));
     set_error_handler(array($this, 'errorHandler'));
     if (function_exists("pcntl_signal")) {
         pcntl_signal(SIGTERM, [$this, 'stopCommand']);
         pcntl_signal(SIGINT, [$this, 'stopCommand']);
     } else {
     }
     $this->isDebug = $input->getArgument('isDebug');
     $port = $input->getOption('port');
     $chat = $this->container->get('app.chat.handler');
     $chat->setIsDebug($this->isDebug);
     $messageManager = new MessageManager($chat);
     $messageManager->setIsDebug($this->isDebug);
     $server = IoServer::factory(new HttpServer(new WsServer($messageManager)), $port);
     if ($this->isDebug) {
         $redis = $this->container->get('snc_redis.default');
         $server->loop->addPeriodicTimer(5, function () use($redis, $messageManager) {
             $memory = memory_get_usage();
             echo "Send messages. Redis value: " . $redis->get('value') . "\r\n";
             $info = array();
             $info['message'] = "Redis value: " . $redis->get('value') . "; Memory: " . $memory;
             $info['type'] = 'message';
             $info['from'] = 'me';
             $messageManager->sendAll(json_encode($info));
         });
     }
     $this->logMessage("Start server.");
     $server->run();
     $this->logMessage("Finish execute daemon.");
 }
开发者ID:tim96,项目名称:webChat,代码行数:35,代码来源:DaemonCommand.php

示例7: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * @var \Symfony\Component\Console\Helper\FormatterHelper
      */
     $formatter = $this->getHelper('formatter');
     $output->writeln($formatter->formatSection('IO', 'Start development server'));
     //        $loop = \React\EventLoop\Factory::create();
     $bridgeName = $input->getOption('bridge');
     switch (strtolower($bridgeName)) {
         case 'phalcony':
             $bridge = new Phalcony();
             break;
         case 'hello':
         default:
             $bridge = new SimpleBridge();
             break;
     }
     $bridge->on('open', function (ConnectionInterface $conn, RequestInterface $request = null) use(&$formatter, $output) {
         $section = $formatter->formatSection('IO', 'Connection is open from ' . $request->getHost() . ' on ' . date('h:i:s') . ' : ' . $request->getUrl());
         $output->writeln($section);
     });
     $bridge->on('close', function (ConnectionInterface $conn, $timer) use(&$formatter, $output) {
         $output->writeln($formatter->formatSection('IO', sprintf('Connection is closed. Request completed %.4F sec.', $timer)));
     });
     $bridge->on('error', function (Exception $e) use(&$formatter, $output) {
         $output->writeln($formatter->formatBlock(array('[App]', $e->getMessage(), 'in the ' . $e->getFile() . ' file on ' . $e->getLine() . ' line'), 'error'));
     });
     $listen = $input->getOption('listen');
     $port = $input->getOption('port');
     $server = IoServer::factory(new HttpServer($bridge), $port, $listen);
     $server->run();
 }
开发者ID:ovr,项目名称:php-pm-reactor,代码行数:33,代码来源:Start.php

示例8: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $port = intval($this->argument('port'));
     $this->info("Starting chat web socket server on port " . $port);
     $server = IoServer::factory(new HttpServer(new WsServer(new ChatController())), $port);
     $server->run();
 }
开发者ID:paulchyrilov,项目名称:hello_laravel,代码行数:12,代码来源:ChatServer.php

示例9: run

 /**
  * @param AbstractMultiRoomServer $chatServer
  * @param int $port
  * @param string $ip
  * @return IoServer
  */
 public static function run(AbstractMultiRoomServer $chatServer, $port, $ip = '0.0.0.0')
 {
     $wsServer = new WsServer($chatServer);
     $http = new HttpServer($wsServer);
     $server = IoServer::factory($http, $port, $ip);
     $server->run();
     return $server;
 }
开发者ID:pmill,项目名称:php-chat,代码行数:14,代码来源:AbstractMultiRoomServer.php

示例10: run

 /**
  * @param Chat $chatServer
  * @param int $port
  * @param string $ip
  * @return IoServer
  */
 public static function run(Chat $chatServer, $port, $ip = '127.0.0.1')
 {
     $wsServer = new WsServer($chatServer);
     $http = new HttpServer($wsServer);
     $server = IoServer::factory($http, $port, $ip);
     $server->run();
     return $server;
 }
开发者ID:pacho104,项目名称:redbpim,代码行数:14,代码来源:Chat.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $port = $input->getOption('port');
     $address = $input->getOption('address');
     $server = IoServer::factory(new HttpServer(new WsServer(new Server($this->getContainer()->get('croupier')))), $port, $address);
     $output->writeln(sprintf('<info>Starting Croupier server on %s:%d.</info>', $address, $port));
     $server->run();
 }
开发者ID:rest-of,项目名称:the-table,代码行数:8,代码来源:CroupierStartCommand.php

示例12: startServer

 private function startServer()
 {
     $ip = $this->config['server']['host'];
     $port = $this->config['server']['port'];
     $server = IoServer::factory(new HttpServer(new WsServer(new \Fr\DiffSocket\Server($this->config))), $port, $ip);
     echo "Server started on {$ip}:{$port}\n";
     $server->run();
 }
开发者ID:subins2000,项目名称:Francium-DiffSocket,代码行数:8,代码来源:DiffSocket.php

示例13: newWorker

 public function newWorker($output, $formatter, $listen, $port, $bridge)
 {
     $pid = pcntl_fork();
     if (!$pid) {
         $output->writeln($formatter->formatSection('App', 'Start slave worker on ' . $listen . ':' . $port . ' pid: ' . $pid));
         $this->slots[] = $server = IoServer::factory(new HttpServer($bridge), $port, $listen);
         $server->run();
     }
 }
开发者ID:ovr,项目名称:php-pm-reactor,代码行数:9,代码来源:Run.php

示例14: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $address = $this->option('address');
     $port = intval($this->option('port'));
     $this->info('Starting web socket server on port ' . $port);
     $server = IoServer::factory(new HttpServer(new WsServer($this->connection)), $port, $address);
     $this->connection->setServer($server);
     $server->run();
 }
开发者ID:edcoreweb,项目名称:dominox,代码行数:14,代码来源:WSServerCommand.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //$chat = $this->getContainer()->get('heliosblog.chat');
     $memcache = new \Memcache();
     $memcache->connect('localhost', 11211);
     $server = IoServer::factory(new HttpServer(new WsServer(new SessionProvider(new Chat1(), new Handler\MemcacheSessionHandler($memcache)))), 8080);
     echo "Chat server is running\n";
     $server->run();
 }
开发者ID:HeliosDX,项目名称:BlogWim1,代码行数:9,代码来源:ChatServerTestCommand.php


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