HproseController.class.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace Think\Controller;
  12. /**
  13. * ThinkPHP Hprose控制器类
  14. */
  15. class HproseController {
  16. protected $allowMethodList = '';
  17. protected $crossDomain = false;
  18. protected $P3P = false;
  19. protected $get = true;
  20. protected $debug = false;
  21. /**
  22. * 架构函数
  23. * @access public
  24. */
  25. public function __construct() {
  26. //控制器初始化
  27. if(method_exists($this,'_initialize'))
  28. $this->_initialize();
  29. //导入类库
  30. Vendor('Hprose.HproseHttpServer');
  31. //实例化HproseHttpServer
  32. $server = new \HproseHttpServer();
  33. if($this->allowMethodList){
  34. $methods = $this->allowMethodList;
  35. }else{
  36. $methods = get_class_methods($this);
  37. $methods = array_diff($methods,array('__construct','__call','_initialize'));
  38. }
  39. $server->addMethods($methods,$this);
  40. if(APP_DEBUG || $this->debug ) {
  41. $server->setDebugEnabled(true);
  42. }
  43. // Hprose设置
  44. $server->setCrossDomainEnabled($this->crossDomain);
  45. $server->setP3PEnabled($this->P3P);
  46. $server->setGetEnabled($this->get);
  47. // 启动server
  48. $server->start();
  49. }
  50. /**
  51. * 魔术方法 有不存在的操作的时候执行
  52. * @access public
  53. * @param string $method 方法名
  54. * @param array $args 参数
  55. * @return mixed
  56. */
  57. public function __call($method,$args){}
  58. }