本文整理匯總了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());
}
}