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


PHP Server::state方法代码示例

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


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

示例1: update

 public function update(Server $server) : Promise
 {
     switch ($server->state()) {
         case Server::STARTED:
             $this->watcherId = \Amp\repeat([$this, "updateTime"], 1000);
             $this->updateTime();
             break;
         case Server::STOPPED:
             \Amp\cancel($this->watcherId);
             $this->watcherId = null;
             break;
     }
     return new Success();
 }
开发者ID:beentrill,项目名称:aerys,代码行数:14,代码来源:Ticker.php

示例2: update

 /**
  * React to server state changes
  *
  * Here we generate our dispatcher when the server notifies us that it is
  * ready to start (Server::STARTING).
  *
  * @param Server $server
  * @return \Amp\Promise
  */
 public function update(Server $server) : Promise
 {
     switch ($this->state = $server->state()) {
         case Server::STOPPED:
             $this->routeDispatcher = null;
             break;
         case Server::STARTING:
             if (empty($this->routes)) {
                 return new Failure(new \DomainException("Router start failure: no routes registered"));
             }
             $this->routeDispatcher = simpleDispatcher(function ($rc) use($server) {
                 $this->buildRouter($rc, $server);
             });
             break;
     }
     return new Success();
 }
开发者ID:beentrill,项目名称:aerys,代码行数:26,代码来源:Router.php

示例3: update

 public function update(Server $server) : Promise
 {
     if ($server->state() === Server::STOPPING) {
         $this->isStopping = true;
     }
     return new Success();
 }
开发者ID:beentrill,项目名称:aerys,代码行数:7,代码来源:Bootstrapper.php

示例4: update

 public function update(Server $server) : Promise
 {
     switch ($this->state = $server->state()) {
         case Server::STARTING:
             $result = $this->application->onStart($this->proxy);
             if ($result instanceof \Generator) {
                 return resolve($result);
             }
             break;
         case Server::STARTED:
             $f = (new \ReflectionClass($this))->getMethod("timeout")->getClosure($this);
             $this->timeoutWatcher = \Amp\repeat($f, 1000);
             break;
         case Server::STOPPING:
             $result = $this->application->onStop();
             if ($result instanceof \Generator) {
                 $promise = resolve($result);
             } elseif ($result instanceof Promise) {
                 $promise = $result;
             } else {
                 $promise = new Success();
             }
             $promise->when(function () {
                 $code = Code::GOING_AWAY;
                 $reason = "Server shutting down!";
                 foreach ($this->clients as $client) {
                     $this->close($client->id, $code, $reason);
                 }
             });
             \Amp\cancel($this->timeoutWatcher);
             $this->timeoutWatcher = null;
             return $promise;
         case Server::STOPPED:
             $promises = [];
             // we are not going to wait for a proper self::OP_CLOSE answer (because else we'd need to timeout for 3 seconds, not worth it), but we will ensure to at least *have written* it
             foreach ($this->clients as $client) {
                 // only if we couldn't successfully send it in STOPPING
                 $code = Code::GOING_AWAY;
                 $reason = "Server shutting down!";
                 $result = $this->doClose($client, $code, $reason);
                 if ($result instanceof \Generator) {
                     $promise[] = resolve($result);
                 }
                 if (!empty($client->writeDeferredControlQueue)) {
                     $promise = end($client->writeDeferredControlQueue)->promise();
                     if ($promise) {
                         $promises[] = $promise;
                     }
                 }
             }
             $promise = any($promises);
             $promise->when(function () {
                 foreach ($this->clients as $client) {
                     $this->unloadClient($client);
                 }
             });
             return $promise;
     }
     return new Success();
 }
开发者ID:staabm,项目名称:aerys,代码行数:60,代码来源:Rfc6455Endpoint.php


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