本文整理汇总了PHP中Server::setProtocol方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::setProtocol方法的具体用法?PHP Server::setProtocol怎么用?PHP Server::setProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::setProtocol方法的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());
}
}
示例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());
}
}