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


PHP Server::service方法代码示例

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


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


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