HproseController.class.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. {
  17. protected $allowMethodList = '';
  18. protected $crossDomain = false;
  19. protected $P3P = false;
  20. protected $get = true;
  21. protected $debug = false;
  22. /**
  23. * 架构函数
  24. * @access public
  25. */
  26. public function __construct()
  27. {
  28. //控制器初始化
  29. if (method_exists($this, '_initialize')) {
  30. $this->_initialize();
  31. }
  32. //导入类库
  33. Vendor('Hprose.HproseHttpServer');
  34. //实例化HproseHttpServer
  35. $server = new \HproseHttpServer();
  36. if ($this->allowMethodList) {
  37. $methods = $this->allowMethodList;
  38. } else {
  39. $methods = get_class_methods($this);
  40. $methods = array_diff($methods, array('__construct', '__call', '_initialize'));
  41. }
  42. $server->addMethods($methods, $this);
  43. if (APP_DEBUG || $this->debug) {
  44. $server->setDebugEnabled(true);
  45. }
  46. // Hprose设置
  47. $server->setCrossDomainEnabled($this->crossDomain);
  48. $server->setP3PEnabled($this->P3P);
  49. $server->setGetEnabled($this->get);
  50. // 启动server
  51. $server->start();
  52. }
  53. /**
  54. * 魔术方法 有不存在的操作的时候执行
  55. * @access public
  56. * @param string $method 方法名
  57. * @param array $args 参数
  58. * @return mixed
  59. */
  60. public function __call($method, $args)
  61. {}
  62. }