當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplSubject::state方法代碼示例

本文整理匯總了PHP中SplSubject::state方法的典型用法代碼示例。如果您正苦於以下問題:PHP SplSubject::state方法的具體用法?PHP SplSubject::state怎麽用?PHP SplSubject::state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SplSubject的用法示例。


在下文中一共展示了SplSubject::state方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 public final function update(\SplSubject $subject) : Promise
 {
     switch ($subject->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:hunslater,項目名稱: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 \SplSubject $subject
  * @return \Amp\Promise
  */
 public function update(\SplSubject $subject) : Promise
 {
     switch ($this->state = $subject->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($subject) {
                 $this->buildRouter($rc, $subject);
             });
             break;
     }
     return new Success();
 }
開發者ID:hunslater,項目名稱:aerys,代碼行數:26,代碼來源:Router.php

示例3: update

 /**
  * Receive notifications from the server when it starts/stops
  *
  * @param \SplSubject $subject
  * @return \Amp\Promise
  */
 public function update(\SplSubject $subject) : amp\Promise
 {
     switch ($subject->state()) {
         case Server::STARTED:
             $this->debug = $subject->getOption("debug");
             amp\enable($this->cacheWatcher);
             break;
         case Server::STOPPED:
             amp\disable($this->cacheWatcher);
             $this->cache = [];
             $this->cacheTimeouts = [];
             $this->cacheEntryCount = 0;
             $this->bufferedFileCount = 0;
             break;
     }
     return new amp\Success();
 }
開發者ID:hunslater,項目名稱:aerys,代碼行數:23,代碼來源:Root.php

示例4: update

 public function update(\SplSubject $subject) : Promise
 {
     switch ($this->state = $subject->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:
             $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;
             break;
         case Server::STOPPED:
             $promises = [];
             $result = $this->application->onStop();
             if ($result instanceof \Generator) {
                 $promises[] = resolve($result);
             }
             // 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) {
                 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:hunslater,項目名稱:aerys,代碼行數:47,代碼來源:Rfc6455Endpoint.php

示例5: update

 public function update(\SplSubject $subject) : Promise
 {
     if ($subject->state() === Server::STOPPING) {
         $this->isStopping = true;
     }
     return new Success();
 }
開發者ID:hunslater,項目名稱:aerys,代碼行數:7,代碼來源:Bootstrapper.php


注:本文中的SplSubject::state方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。