本文整理汇总了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();
}
示例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');
}
示例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();
示例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();
示例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";
}
示例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();