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


PHP Server类代码示例

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


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

示例1: forge

 public static function forge($request)
 {
     $server = new Server();
     $server->setRequest($request);
     $server->parse();
     return $server;
 }
开发者ID:T-REX-XP,项目名称:UPnP,代码行数:7,代码来源:Server.php

示例2: 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

示例3: __construct

 public function __construct(array $options = null)
 {
     if (!is_array($options)) {
         $options = [];
     }
     if (empty($options["smtpServer"])) {
         $hostname = "localhost";
     } else {
         $hostname = $options["smtpServer"];
     }
     if ($hostname === "localhost") {
         $port = isset($options["local-port"]) ? $options["local-port"] : 25;
     } else {
         $port = isset($options["port"]) ? $options["port"] : 465;
     }
     $server = new Server($hostname, $port);
     if (!empty($options["username"]) || !empty($options["password"])) {
         $server->setCredentials($options["username"], $options["password"]);
     }
     if (!empty($options["encryption"])) {
         $server->setEncryptionMethod($options["encryption"]);
     }
     if (!empty($options["returnPath"])) {
         $server->setReturnPath($options["returnPath"]);
     }
     parent::__construct($server);
     if (!empty($options["fromAddress"])) {
         $this->setFromAddress($options["fromAddress"], $options["fromName"]);
     }
 }
开发者ID:duncan3dc,项目名称:swiftmailer,代码行数:30,代码来源:Mailer.php

示例4: send

 /**
  * @param string $url
  * @param array $params [optional]
  * @return State
  */
 function send($url, array $params = null)
 {
     if ($data = $this->server->send($url, $params)) {
         return new State($data);
     }
     throw new ServerException("Bad Response from Server");
 }
开发者ID:eridal,项目名称:vindinium,代码行数:12,代码来源:Client.php

示例5: testServerAcceptClient

 public function testServerAcceptClient()
 {
     self::$server->onConnectPeer(function (Peer $peer) {
         self::$peer_accepted++;
     });
     self::$server->listen();
 }
开发者ID:maestroprog,项目名称:esockets-php,代码行数:7,代码来源:TestEsocketsLinear.php

示例6: getStreamSrc

 public function getStreamSrc($args, $querySep = '&amp;')
 {
     if (isset($this->{'ServerId'}) and $this->{'ServerId'}) {
         $Server = new Server($this->{'ServerId'});
         $streamSrc = ZM_BASE_PROTOCOL . '://' . $Server->Hostname() . ZM_PATH_ZMS;
     } else {
         $streamSrc = ZM_BASE_URL . ZM_PATH_ZMS;
     }
     $args[] = "monitor=" . $this->{'Id'};
     if (ZM_OPT_USE_AUTH) {
         if (ZM_AUTH_RELAY == "hashed") {
             $args[] = "auth=" . generateAuthHash(ZM_AUTH_HASH_IPS);
         } elseif (ZM_AUTH_RELAY == "plain") {
             $args[] = "user=" . $_SESSION['username'];
             $args[] = "pass=" . $_SESSION['password'];
         } elseif (ZM_AUTH_RELAY == "none") {
             $args[] = "user=" . $_SESSION['username'];
         }
     }
     if (!in_array("mode=single", $args) && !empty($GLOBALS['connkey'])) {
         $args[] = "connkey=" . $GLOBALS['connkey'];
     }
     if (ZM_RAND_STREAM) {
         $args[] = "rand=" . time();
     }
     if (count($args)) {
         $streamSrc .= "?" . join($querySep, $args);
     }
     return $streamSrc;
 }
开发者ID:schrorg,项目名称:ZoneMinder,代码行数:30,代码来源:Monitor.php

示例7: testListen_shouldDieIfAttemptsLimit

 public function testListen_shouldDieIfAttemptsLimit()
 {
     $server = new Server($this->createMockStore([[], [], ['test']]));
     $server->setDelay(0.1);
     $server->setAttemptsLimit(2);
     $events = $server->listen(time());
     $this->assertEquals([], $events, 'Завершение работы при достижении attemptsLimit');
 }
开发者ID:bashka,项目名称:bricks_http_realtimeserver_longpolling,代码行数:8,代码来源:ServerTest.php

示例8: factory

 public static function factory($socket)
 {
     $context = new \ZMQContext();
     $socketDealer = $context->getSocket(\ZMQ::SOCKET_DEALER);
     $queueServer = new Server($socketDealer);
     $queueServer->setSocket($socket);
     return $queueServer;
 }
开发者ID:gonzalo123,项目名称:zmqlifo,代码行数:8,代码来源:Server.php

示例9: showAction

 public function showAction(Server $server, Player $me, Request $request)
 {
     if ($server->staleInfo()) {
         $server->forceUpdate();
     }
     if ($request->get('forced') && $me->canEdit($server)) {
         $server->forceUpdate();
     }
     return array("server" => $server);
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:ServerController.php

示例10: saveSmd

 /**
  * Cache a service map description (SMD) to a file
  *
  * Returns true on success, false on failure
  *
  * @param  string $filename
  * @param  \Zend\Json\Server\Server $server
  * @return boolean
  */
 public static function saveSmd($filename, Server $server)
 {
     if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) {
         return false;
     }
     if (0 === @file_put_contents($filename, $server->getServiceMap()->toJson())) {
         return false;
     }
     return true;
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:19,代码来源:Cache.php

示例11: console

 /**
  * Execute commands as console
  *
  * @param Server $server - pocketmine\Server instance
  * @param str[]|str $cmd - commands to execute
  * @param bool $show - show commands being executed
  */
 public static function console($server, $cmd, $show = false)
 {
     if (!is_array($cmd)) {
         $cmd = [$cmd];
     }
     foreach ($cmd as $c) {
         if ($show) {
             $server->getLogger()->info("CMD> {$cmd}");
         }
         $server->dispatchCommand(new ConsoleCommandSender(), $c);
     }
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:19,代码来源:Cmd.php

示例12: testUpdatePropertiesEventSuccess

 function testUpdatePropertiesEventSuccess()
 {
     $tree = [new SimpleCollection('foo')];
     $server = new Server($tree);
     $server->on('propPatch', function ($path, PropPatch $propPatch) {
         $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () {
             return ['{DAV:}foo' => 200, '{DAV:}foo2' => 201];
         });
     });
     $result = $server->updateProperties('foo', ['{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla']);
     $expected = ['{DAV:}foo' => 200, '{DAV:}foo2' => 201];
     $this->assertEquals($expected, $result);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:13,代码来源:ServerUpdatePropertiesTest.php

示例13: 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

示例14: hproseserver_call

function hproseserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(__DIR__) . "/application");
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $hprose_config = $config_obj->hprose->toArray();
    $server = new Server("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port']);
    $server->setErrorTypes(E_ALL);
    $server->setDebugEnabled();
    $server->addFunction('zys');
    $server->start();
}
开发者ID:qieangel2013,项目名称:zys,代码行数:14,代码来源:server.php

示例15: setPool

 public function setPool()
 {
     $pool = new Pool();
     foreach ($this->getConfiguration() as $key => $value) {
         $array = new ArrayObject($value);
         $server = new Server();
         $server->setHost($array->offsetGet(self::SERVER_PROPERTY_HOST))->setPort($array->offsetGet(self::SERVER_PROPERTY_PORT))->setName($key);
         if ($array->offsetExists(self::SERVER_PROPERTY_AUTH)) {
             $server->setAuth($array->offsetGet(self::SERVER_PROPERTY_AUTH));
         }
         $pool->attach($server);
     }
     $this->pool = $pool;
 }
开发者ID:tin-cat,项目名称:redis-info,代码行数:14,代码来源:Config.php


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