Inheritance: extends Hprose\Service
Beispiel #1
0
 public function __construct($uri, $mode = SWOOLE_BASE)
 {
     parent::__construct();
     $url = $this->parseUrl($uri);
     $this->type = $url->type;
     $this->server = new swoole_server($url->host, $url->port, $mode, $url->type);
 }
Beispiel #2
0
 public function __construct()
 {
     $this->serv = new swoole_http_server("0.0.0.0", 9501);
     $this->serv->set(array('worker_num' => 1, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 2));
     $this->serv->on('Start', array($this, 'onStart'));
     $this->serv->on('Connect', array($this, 'onConnect'));
     $this->serv->on('Request', array($this, 'onRequest'));
     $this->serv->on('Close', array($this, 'onClose'));
     // add rpc port
     $port = $this->serv->listen("0.0.0.0", 9502, SWOOLE_SOCK_TCP);
     $port->set(['open_eof_split' => false]);
     $rpc_service = new Service();
     $rpc_service->socketHandle($port);
     $rpc_service->addFunction(array($this, 'upload'));
     // add udp port
     $udp_port = $this->serv->listen("0.0.0.0", 9503, SWOOLE_SOCK_UDP);
     $udp_port->on('packet', function ($serv, $data, $addr) {
         var_dump($data, $addr);
     });
     $this->serv->start();
 }
 public function __construct()
 {
     $this->serv = new Server("http://0.0.0.0:9501");
     $this->serv->set(array('worker_num' => 1, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 2));
     $this->serv->on('Start', array($this, 'onStart'));
     $this->serv->on('WorkerStart', array($this, 'onWorkerStart'));
     // 加载配置文件
     $config = (require "config.php");
     // 在这里注册对外服务接口
     foreach ($config['api_list'] as $controller) {
         require_once __DIR__ . "/ctrl/{$controller}.php";
         $this->serv->add(new $controller());
     }
     $port = $this->serv->listen("0.0.0.0", 9502, SWOOLE_SOCK_TCP);
     $rpc_service = new Service();
     $rpc_service->socketHandle($port);
     foreach ($config['api_list'] as $controller) {
         require_once __DIR__ . "/ctrl/{$controller}.php";
         $rpc_service->add(new $controller());
     }
     $this->serv->start();
 }