Exemplo n.º 1
0
 public function actionIndex()
 {
     $server = new HproseHttpServer();
     $server->setCrossDomainEnabled(true);
     $server->addInstanceMethods($this);
     $server->handle();
     exit;
 }
Exemplo n.º 2
0
 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');
     //实例化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();
 }
 /**
  * 架构函数
  * @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();
 }
Exemplo n.º 5
0
        $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();
Exemplo n.º 6
0
	载入基本函数库
*/
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 {
    /*
Exemplo n.º 7
0
<?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();
<?php

require_once 'hprose-php/src/Hprose.php';
require_once 'hprose-filter-init.php';
function onBeforeInvoke($name, &$args, $byref, $context)
{
    foreach ($args as $k => $arg) {
        $args[$k] = decrypt($arg);
    }
}
function onAfterInvoke($name, &$args, $byref, &$result, $context)
{
    $result = encrypt($result);
}
function testFilter($name)
{
    return 'Args: ' . $name;
}
$server = new HproseHttpServer();
$server->addFilter(new serverFilter());
// 只加密参数启用
// $server->onBeforeInvoke = 'onBeforeInvoke';
// $server->onAfterInvoke  = 'onAfterInvoke';
$server->addFunction('testFilter');
$server->start();