/** * 架构函数 * @access public */ public function __construct() { //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } //导入类库 Vendor('Hprose.HproseHttpServer'); //实例化HproseHttpServer $server = new \HproseHttpServer(); if ($this->allowMethodList) { $methods = $this->allowMethodList; } else { $methods = get_class_methods($this); $methods = array_diff($methods, array('__construct', '__call', '_initialize')); } $server->addMethods($methods, $this); if (APP_DEBUG || $this->debug) { $server->setDebugEnabled(true); } // Hprose设置 $server->setCrossDomainEnabled($this->crossDomain); $server->setP3PEnabled($this->P3P); $server->setGetEnabled($this->get); // 启动server $server->start(); }
public function httpserverAction() { function hello($name) { echo "Hello {$name}!"; return "Hello {$name}!"; } function e() { throw new Exception("I am Exception"); } function ee() { require "andot"; } function asyncHello($name, $callback) { sleep(3); $callback("Hello async {$name}!"); } $server = new HproseHttpServer(); $server->setErrorTypes(E_ALL); $server->setDebugEnabled(); $server->addFunction('hello'); $server->addFunctions(array('e', 'ee')); $server->add(new TestModel(), "", 'test'); $server->addAsyncFunction('asyncHello'); $server->start(); return false; }
/** * 架构函数 * @access public */ public function __construct() { //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } //导入类库 Vendor('Hprose.HproseHttpServer'); //实例化phprpc $server = new \HproseHttpServer(); if ($this->allowMethodList) { $methods = $this->allowMethodList; } else { $methods = get_class_methods($this); } $server->addMethods($methods, $this); if (APP_DEBUG) { $server->setDebugEnabled(true); } $server->start(); }
*/ require_once "./include/friextra_common_inc.php"; $rpc_name = 'rpcpbx'; $rpc_version = '2.0'; $freeiris_conf = null; //$asterisk_conf=null; $manager_conf = null; $dbcon = null; //PHP使用最大允许内存 ini_set("memory_limit", "128M"); initrpc(); /* 生成RPC对象 */ $server = new HproseHttpServer(); $server->setDebugEnabled(true); /* 注册开放式RPC基本服务 */ $server->add('base_clientlogin'); // 注册登记 /* 注册非开放式RPC基本服务 */ //验证请求者权限 session_start(); if (!isset($_SESSION["client_authorized"]) || $_SESSION["client_authorized"] == false) { //身份验证失败,不再发布其他函数. } else { /* 载入所有服务模块文件
<?php require_once '../src/Hprose.php'; function hello($name) { echo "Hello {$name}!"; return "Hello {$name}!"; } function e() { throw new Exception("I am Exception"); } function ee() { require "andot"; } function asyncHello($name, $callback) { sleep(3); $callback("Hello async {$name}!"); } $server = new HproseHttpServer(); $server->setErrorTypes(E_ALL); $server->setDebugEnabled(); $server->addFunction('hello'); $server->addFunctions(array('e', 'ee')); $server->addAsyncFunction('asyncHello'); $server->addFilter(new HproseJSONRPCServiceFilter()); $server->start();