public function before() { Core::close_buffers(false); $this->phprpc = PHPRPC::server(); $this->auto_add_action(); $this->before_start(); if (IS_DEBUG) { $this->phprpc->setDebugMode(true); } $this->phprpc->start(); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { //导入类库 Vendor('phpRPC.phprpc_server'); //实例化phprpc $server = new PHPRPC_Server(); $actions = explode(',', C('APP_PHPRPC_ACTIONS')); foreach ($actions as $action) { //$server -> setClass($action.'Action'); $temp = $action . 'Action'; $methods = get_class_methods($temp); $server->add($methods, new $temp()); } if (APP_DEBUG) { $server->setDebugMode(true); } $server->setEnableGZIP(true); $server->start(); //C('PHPRPC_COMMENT',$server->comment()); echo $server->comment(); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
public function index() { require_once Kohana::find_file('vendor', 'phprpc/phprpc_server', TRUE); $server = new PHPRPC_Server(); $server->add(array('get_data_pv_ip_by_time', 'get_data_pv_ip_by_time_range', 'get_data_domain_by_time_range', 'get_data_page_by_time_range', 'get_data_country_by_time_range', 'get_data_pv_ip_by_one_site', 'get_data_source_by_time_range'), new Rpcserver_Controller()); $server->start(); }
function serverAction() { // ini_set("soap.wsdl_cache_enabled", "0"); // $soap = new SoapServer("wf.wsdl"); // this current file here // $soap->setClass('PointService'); // $soap->handle(); $server = new PHPRPC_Server(); $server->add('decrypt', new PointService()); $server->add('verifyAccount', new PointService()); $server->add('exchange', new PointService()); $server->add('getCurrentPoint', new PointService()); $server->setCharset('UTF-8'); $server->start(); $this->_helper->layout->disableLayout(); }
/** * PHPRpc控制器架构函数 * @access public */ public function __construct() { //导入类库 think\loader::import('vendor.phprpc.phprpc_server'); //实例化phprpc $server = new \PHPRPC_Server(); $server->add($this); if (APP_DEBUG) { $server->setDebugMode(true); } $server->setEnableGZIP(true); $server->start(); //C('PHPRPC_COMMENT',$server->comment()); echo $server->comment(); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { // 设定错误和异常处理 set_error_handler(array('App', "appError")); set_exception_handler(array('App', "appException")); //[RUNTIME] // 检查项目是否编译过 // 在部署模式下会自动在第一次执行的时候编译项目 if (defined('RUNTIME_MODEL')) { // 运行模式无需载入项目编译缓存 } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) { // 直接读取编译后的项目文件 C(include RUNTIME_PATH . '~app.php'); } else { // 预编译项目 App::build(); } //[/RUNTIME] //导入类库 Vendor('phpRPC.phprpc_server'); //实例化phprpc $server = new PHPRPC_Server(); $actions = explode(',', C('APP_PHPRPC_ACTIONS')); foreach ($actions as $action) { //$server -> setClass($action.'Action'); $temp = $action . 'Action'; $methods = get_class_methods($temp); $server->add($methods, new $temp()); } if (C('APP_DEBUG')) { $server->setDebugMode(true); } $server->setEnableGZIP(true); $server->start(); //C('PHPRPC_COMMENT',$server->comment()); echo $server->comment(); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
/** * 架构函数 * @access public */ public function __construct() { //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } //实例化phprpc $server = new \PHPRPC_Server(); if ($this->allowMethodList) { $methods = $this->allowMethodList; } else { $methods = get_class_methods($this); $methods = array_diff($methods, array('__construct', '__call', '_initialize')); } $server->add($methods, $this); if (APP_DEBUG || $this->debug) { $server->setDebugMode(true); } $server->setEnableGZIP(true); $server->start(); echo $server->comment(); }
/** * 架构函数 * @access public */ public function __construct() { //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } //导入类库 Vendor('phpRPC.phprpc_server'); //实例化phprpc $server = new \PHPRPC_Server(); if ($this->allowMethodList) { $methods = $this->allowMethodList; } else { $methods = get_class_methods($this); } $server->add($methods, $this); if (APP_DEBUG) { $server->setDebugMode(true); } $server->setEnableGZIP(true); $server->start(); echo $server->comment(); }
$server->add('extengroup_list'); #分组列表 $server->add('extengroup_get'); #查看分组 $server->add('extengroup_add'); #新增分组 $server->add('extengroup_edit'); #编辑分组 $server->add('extengroup_delete'); #删除分组 // 原形接口 $server->add('dbquery'); #数据库函数原形接口 $server->add('client_login'); #身份验证基本函数 $server->start(); /* FRIPAPER @name extension_list @synopsis $fri2struct extension_list (string $order,int $limitfrom,int $limitoffset) @param $order 排序方式设置 @item 'order by xxxx'
public function start() { parent::start(); }
/** * rpc服务 */ public function attachment() { $returnStruct = array('status' => 0, 'code' => 501, 'msg' => _('Not Implemented'), 'content' => array()); try { //* 初始化返回数据 */ $returnStatus = 1; $returnCode = 200; $returnMessage = ''; $returnData = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $requestData = $this->input->get(); //* 实现功能后屏蔽此异常抛出 */ //throw new MyRuntimeException(_('Not Implemented'),501); //* 权限验证,数据验证,逻辑验证 ==根据业务逻辑定制== */ //if(util::isAccess(array(Logon::$MGR_ROLE_LABEL_SYS_ADMIN,), array(Logon::$USER_ROLE_LABEL_DENIED,Logon::$USER_ROLE_LABEL_GUEST), $this->getUserRoleLabel())==FALSE){ // throw new MyRuntimeException(_('Access Denied'),403); //} if (util::isAccess('*', array(Logon::$USER_ROLE_LABEL_DENIED), $this->getUserRoleLabel()) == FALSE) { throw new MyRuntimeException(_('Access Denied'), 403); } //* 权限验证 ==根据业务逻辑定制== */ //* 数据验证 ==根据业务逻辑定制== */ //* 逻辑验证 ==根据业务逻辑定制== */ // 调用底层服务 !isset($servRouteInstance) && ($servRouteInstance = ServRouteInstance::getInstance(ServRouteConfig::getInstance())); // 执行业务逻辑 require_once Lemon::find_file('vendor', 'phprpc/phprpc_server', TRUE); $server = new PHPRPC_Server(); $server->add(array('phprpc_addAttachmentFileData', 'phprpc_getAttachmentDataById', 'phprpc_getStoreDataByStoreId', 'phprpc_getStoreDataByAttachmentId', 'phprpc_removeAttachmentDataByAttachmentId', 'phprpc_getStoreInfoByStoreId'), Attachment_Service::getInstance()); $server->start(); exit; throw new MyRuntimeException(_('Internal Error'), 500); //* 补充&修改返回结构体 */ $returnStruct['status'] = $returnStatus; $returnStruct['code'] = $returnCode; $returnStruct['msg'] = $returnMessage; $returnStruct['content'] = $returnData; //* 请求类型 */ if ($this->isAjaxRequest()) { // ajax 请求 // json 输出 $this->template->content = $returnStruct; } else { // html 输出 //* 模板输出 */ $this->template->returnStruct = $returnStruct; $content = new View('info'); //* 变量绑定 */ $this->template->title = Lemon::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->requestData = $requestData; //* 返回结构体绑定 */ $this->template->content->returnStruct = $returnStruct; //:: 当前应用专用数据 $this->template->content->title = Lemon::config('site.name'); } // end of request type determine } catch (MyRuntimeException $ex) { $returnStruct['status'] = 0; $returnStruct['code'] = $ex->getCode(); $returnStruct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->isAjaxRequest()) { $this->template->content = $returnStruct; } else { $this->template->returnStruct = $returnStruct; $content = new View('info'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->requestData = $requestData; //* 返回结构体绑定 */ $this->template->content->returnStruct = $returnStruct; } } }
public function response() { $server = new PHPRPC_Server(); $server->add(array('response'), $this->phalapiProxy); $server->start(); }