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


PHP Server::listen方法代碼示例

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


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

示例1: testServerAcceptClient

 public function testServerAcceptClient()
 {
     self::$server->onConnectPeer(function (Peer $peer) {
         self::$peer_accepted++;
     });
     self::$server->listen();
 }
開發者ID:maestroprog,項目名稱:esockets-php,代碼行數:7,代碼來源:TestEsocketsLinear.php

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

示例3: Server

 * Copyright (c) sk89q <http://sk89q.therisenrealm.com>
 * Licensed under the GNU General Public License v3
*/
require 'config.php';
require 'server.php';
require 'shoutcast.php';
require 'audiosource.php';
require 'http.php';
set_time_limit(0);
$Server = new Server();
$AudioSource = new AudioSource();
$AudioSource->bitrate = $CONFIG['bitrate'];
$AudioSource->encoder = $CONFIG['encoder_path'];
$AudioSource->metadata_interval = $CONFIG['metadata_interval'];
$AudioSource->populate_playlist($CONFIG['music_dir']);
$AudioSource->open_next_file();
$Shoutcast = new Shoutcast();
$Shoutcast->server =& $Server;
$Shoutcast->source =& $AudioSource;
$Shoutcast->metadata_interval = $CONFIG['metadata_interval'];
$Shoutcast->server_name = $CONFIG['server_name'];
$Shoutcast->server_genre = $CONFIG['server_genre'];
$Shoutcast->server_url = $CONFIG['server_url'];
$Shoutcast->server_public = $CONFIG['server_public'];
$Shoutcast->hook_to_server();
$HTTP = new HTTP();
$HTTP->server =& $Server;
$HTTP->shoutcast =& $Shoutcast;
$HTTP->hook_to_server();
$Server->listen();
開發者ID:sk89q,項目名稱:PHP-Shoutcast-Server,代碼行數:30,代碼來源:run.php

示例4: trim

            $address = trim(array_shift($args));
            break;
        case "-d":
            $document_root = trim(array_shift($args));
            break;
        case "--help":
            $help = true;
            break;
        case "--rewrite":
            $rewrite = true;
            break;
    }
}
if ($help) {
    print "Usage: {$script} [-p port] [-h host] [-d document_root] [--rewrite] [--help]\n";
    print "\nCurrent settings:\n";
    print "* Host          - {$address}\n";
    print "* Port          - {$port}\n";
    print "* Document Root - {$document_root}\n";
    print "* Rewrite Rule  - " . ($rewrite ? "On" : "Off") . "\n";
    exit;
}
// Strip any trailing slash from the document root
$document_root = preg_replace("!^(.*)/\$!", "\$1", $document_root);
$server = new Server($address, $port);
$server->document_root = $document_root;
if ($rewrite) {
    $server->handler_options["rewrite"] = true;
}
$server->listen();
開發者ID:jon9872,項目名稱:zend-framework,代碼行數:30,代碼來源:server-start.php

示例5: die

<?php

include './config.php';
if ($argc != 3) {
    die("Usage: {$argv[0]} host port\n");
}
$myServer = new Server($argv[1], $argv[2]);
echo $myServer->showStatus();
$myServer->startUp();
echo $myServer->showStatus();
while (($string = $myServer->listen()) !== false) {
    echo getTimestamp() . " Got string of '{$string}'\n";
}
開發者ID:robertkeizer,項目名稱:php-udp,代碼行數:13,代碼來源:server.php

示例6: doWork

class Server extends \FastD\Swoole\Server\Tcp
{
    /**
     * @param swoole_server $server
     * @param $fd
     * @param $data
     * @param $from_id
     * @return mixed
     */
    public function doWork(swoole_server $server, $fd, $data, $from_id)
    {
        return 'hello server1';
    }
}
class Server2 extends \FastD\Swoole\Server\Tcp
{
    /**
     * @param swoole_server $server
     * @param $fd
     * @param $data
     * @param $from_id
     * @return mixed
     */
    public function doWork(swoole_server $server, $fd, $data, $from_id)
    {
        return 'hello server2';
    }
}
$server = new Server('tcp://127.0.0.1:9527');
$server->listen(new Server2('tcp://127.0.0.1:9528'));
$server->start();
開發者ID:JanHuang,項目名稱:swoole,代碼行數:31,代碼來源:multi_port_server.php


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