Skip to content

Commit

Permalink
fixed #250 websocket header信息检查时不区分大小写
Browse files Browse the repository at this point in the history
暴露addWorker方法,方便用户自定义进程
  • Loading branch information
yunwuxin committed Jun 4, 2021
1 parent 61c4b9f commit 915ce6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/concerns/InteractsWithHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/concerns/InteractsWithServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ 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;
}
return $this;
}

protected function addWorker(callable $func): self
public function addWorker(callable $func): self
{
$this->addBatchWorker(1, $func);
return $this;
Expand All @@ -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)) {
Expand Down

0 comments on commit 915ce6e

Please sign in to comment.