From 915ce6efe9cb36949d06a285554a11ab56ca7c44 Mon Sep 17 00:00:00 2001 From: yunwuxin <448901948@qq.com> Date: Fri, 4 Jun 2021 12:49:08 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20#250=20websocket=20header=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=A3=80=E6=9F=A5=E6=97=B6=E4=B8=8D=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=20=E6=9A=B4=E9=9C=B2addWorker?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=96=B9=E4=BE=BF=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/concerns/InteractsWithHttp.php | 4 ++-- src/concerns/InteractsWithServer.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) 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)) {