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


PHP Server::init方法代碼示例

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


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

示例1: main

 /**
  * Start server
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $stor = new TestingStorage();
     $stor->add(new TestingCollection('/', $stor));
     $stor->add(new TestingCollection('/.trash', $stor));
     $stor->add(new TestingElement('/.trash/do-not-remove.txt', $stor));
     $stor->add(new TestingCollection('/htdocs', $stor));
     $stor->add(new TestingElement('/htdocs/file with whitespaces.html', $stor));
     $stor->add(new TestingElement('/htdocs/index.html', $stor, "<html/>\n"));
     $stor->add(new TestingCollection('/outer', $stor));
     $stor->add(new TestingCollection('/outer/inner', $stor));
     $stor->add(new TestingElement('/outer/inner/index.html', $stor));
     $auth = newinstance('lang.Object', array(), '{
     public function authenticate($user, $password) {
       return ("testtest" == $user.$password);
     }
   }');
     $protocol = newinstance('peer.ftp.server.FtpProtocol', array($stor, $auth), '{
     public function onShutdown($socket, $params) {
       $this->answer($socket, 200, "Shutting down");
       $this->server->terminate= TRUE;
     }
   }');
     isset($args[0]) && $protocol->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender($args[0])));
     $s = new Server('127.0.0.1', 0);
     try {
         $s->setProtocol($protocol);
         $s->init();
         Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
         $s->service();
         Console::writeLine('+ Done');
     } catch (Throwable $e) {
         Console::writeLine('- ', $e->getMessage());
     }
 }
開發者ID:Gamepay,項目名稱:xp-framework,代碼行數:40,代碼來源:TestingServer.class.php

示例2: main

    /**
     * Start server
     *
     * @param   string[] args
     */
    public static function main(array $args)
    {
        // Add shutdown message handler
        EascMessageFactory::setHandler(61, newinstance('remote.server.message.EascMessage', array(), '{
        public function getType() { 
          return 61; 
        }
        public function handle($protocol, $data) {
          Logger::getInstance()->getCategory()->debug("Shutting down");
          $protocol->server->terminate= TRUE; 
        }
      }')->getClass());
        $s = new Server('127.0.0.1', 0);
        try {
            $protocol = new EascProtocol(newinstance('remote.server.deploy.scan.DeploymentScanner', array(), '{
          private $changed= TRUE;

          public function scanDeployments() {
            $changed= $this->changed;
            $this->changed= FALSE;
            return $changed;
          }

          public function getDeployments() {
            $res= "net/xp_framework/unittest/remote/deploy/beans.test.CalculatorBean.xar";

            with ($d= new Deployment($res)); {
              $d->setClassLoader(new ArchiveClassLoader(new Archive(ClassLoader::getDefault()->getResourceAsStream($res))));
              $d->setImplementation("beans.test.CalculatorBeanImpl");
              $d->setInterface("beans.test.Calculator");
              $d->setDirectoryName("xp/test/Calculator");

              return array($d);
            }
          }
        }'));
            $protocol->initialize();
            $s->setProtocol($protocol);
            $s->init();
            Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
            $s->service();
            Console::writeLine('+ Done');
        } catch (Throwable $e) {
            Console::writeLine('- ', $e->getMessage());
        }
    }
開發者ID:Gamepay,項目名稱:xp-framework,代碼行數:51,代碼來源:TestingServer.class.php

示例3: init

 /**
  * Initialize the server
  *
  */
 public function init()
 {
     parent::init();
     $this->socket->setBlocking(FALSE);
 }
開發者ID:Gamepay,項目名稱:xp-framework,代碼行數:9,代碼來源:PreforkingServer.class.php


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