diff --git a/src/concerns/InteractsWithHttp.php b/src/concerns/InteractsWithHttp.php index 1b7c16e..0d87ec8 100644 --- a/src/concerns/InteractsWithHttp.php +++ b/src/concerns/InteractsWithHttp.php @@ -37,8 +37,8 @@ public function createHttpServer() $server->handle('/', function (Request $req, Response $res) { $header = $req->header; - if (Arr::get($header, 'connection') == 'upgrade' && - Arr::get($header, 'upgrade') == 'websocket' && + if (strcasecmp(Arr::get($header, 'connection'), 'upgrade') === 0 && + strcasecmp(Arr::get($header, 'upgrade'), 'websocket') === 0 && $this->wsEnable ) { $this->onHandShake($req, $res); diff --git a/src/concerns/InteractsWithServer.php b/src/concerns/InteractsWithServer.php index 6d3ebaa..5b9929e 100644 --- a/src/concerns/InteractsWithServer.php +++ b/src/concerns/InteractsWithServer.php @@ -29,7 +29,7 @@ trait InteractsWithServer /** @var Pool */ protected $pool; - protected function addBatchWorker(int $workerNum, callable $func) + public function addBatchWorker(int $workerNum, callable $func) { for ($i = 0; $i < $workerNum; $i++) { $this->startFuncMap[] = $func; @@ -37,7 +37,7 @@ protected function addBatchWorker(int $workerNum, callable $func) return $this; } - protected function addWorker(callable $func): self + public function addWorker(callable $func): self { $this->addBatchWorker(1, $func); return $this; @@ -50,9 +50,10 @@ public function start(): void { Runtime::enableCoroutine(); + $this->setProcessName('manager process'); + $this->initialize(); $this->triggerEvent('init'); - $this->setProcessName('manager process'); //热更新 if ($this->getConfig('hot_update.enable', false)) {