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; }
$this->_sign = $sign['sign']; $this->_timestamp = $sign['timestamp']; $this->_module = self::CLASS_PREFIX . ucfirst($module); // //如果没有通过接口安全验证返回FALSE if ($this->verify() !== true) { return $this->verify(); } #如果你框架有自动加载机制请注释掉以下代码 include $this->_module . ".php"; #如果你框架有自动加载机制请注释掉以上代码 //判断请求模块是否存在 if (!class_exists($this->_module)) { return 'module error'; } //实例化服务模型 $cls = new $this->_module(); //初始化api名称,判断请求方法是否存在 $methodName = self::API_PREFIX . ucfirst($methodName); if (!method_exists($cls, $methodName)) { return 'method error'; } //判断参数是否数组 if (empty($pramas) || !is_array($pramas)) { $pramas = []; } return call_user_func_array([$cls, $methodName], $pramas); } } $service = new HproseHttpServer(); $service->add(new HService()); $service->start();
$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 { /* 载入所有服务模块文件 文件格式rpcpbx_[服务名称].php */ if ($serviceloader_dir_handle = opendir(getcwd())) { while (($servicefile = readdir($serviceloader_dir_handle)) !== false) {