當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。