服务端
<?php
use think\Container;
class Http{
CONST HOST = "0.0.0.0";
CONST PORT = 8811;
public $http = null;
public function __construct()
{
$this->http = new swoole_http_server(self::HOST,self::PORT);
$this->http->set([
'enable_static_handler' => true,//开启静态页面访问
'worker_num' => 4,
'task_worker_num' => 4,
'document_root' => "/usr/local/var/www/swoole_mooc/thinkphp/public/static",
]);
$this->http->on("workerstart",[$this,'onWorkerStart']);
$this->http->on("request",[$this,'onRequest']);
$this->http->on("task", [$this,'onTask']);
$this->http->on("finish", [$this,'onFinish'