コード例 #1
0
ファイル: Server.php プロジェクト: jgswift/qtcp
 public function __construct(Application $app)
 {
     $this->application = $app;
     $this->console = $app->getConsole();
     $this->clients = [];
     $this->reader = new Stream\Reader($app->getProtocol());
 }
コード例 #2
0
ファイル: Provider.php プロジェクト: jgswift/qtcp
 function __construct(qtcp\Application $application)
 {
     $this->application = $application;
     $loop = \React\EventLoop\Factory::create();
     $loop->addPeriodicTimer($application->clock->getSpeed(), function () {
         $this->application->clock->tick();
         $clients = $this->application->getServer()->getClients();
         // INCREASE IDLE TIME ON ALL CLIENTS
         if (!empty($clients)) {
             foreach ($clients as $client) {
                 $client->idle();
                 //KICK CLIENTS IDLING OVER 15 MINUTES
                 if ($client->isIdle()) {
                     $client->close();
                 }
             }
         }
     });
     $component = new HttpServer(new WsServer($this->server = new \qtcp\Server($application)));
     $socket = new \React\Socket\Server($loop);
     $resource = $application->getResource();
     $socket->listen($resource->getPort(), $resource->getPath());
     $this->io = new IoServer($component, $socket, $loop);
 }