/**
  * 架构函数
  * @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();
 }
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');
     //实例化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.º 4
0
        $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.º 5
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();