Skip to content

Commit

Permalink
修复 Workerman Gateway 兼容性 (#469)
Browse files Browse the repository at this point in the history
* 修复 Workerman Gateway 兼容性

* 修复测试
  • Loading branch information
Yurunsoft committed Feb 10, 2023
1 parent bb426d4 commit 66e6c0a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public function handle(EventParam $e): void
if ($registerAddress = Config::get('@app.mainServer.workermanGateway.registerAddress'))
{
Gateway::$registerAddress = $registerAddress;
// @phpstan-ignore-next-line
if (isset(Gateway::$persistentConnection))
{
Gateway::$persistentConnection = false;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ protected function initGatewayWorker(): void
if (isset($workermanGatewayConfig['registerAddress']))
{
Gateway::$registerAddress = $workermanGatewayConfig['registerAddress'];
// @phpstan-ignore-next-line
if (isset(Gateway::$persistentConnection))
{
Gateway::$persistentConnection = false;
}
}

Coroutine::create(function () use ($workermanGatewayConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ protected function initGatewayWorker(): void
if (isset($workermanGatewayConfig['registerAddress']))
{
Gateway::$registerAddress = $workermanGatewayConfig['registerAddress'];
// @phpstan-ignore-next-line
if (isset(Gateway::$persistentConnection))
{
Gateway::$persistentConnection = false;
}
}

Coroutine::create(function () use ($workermanGatewayConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public function handle(EventParam $e): void
if (isset($item['configs']['registerAddress']))
{
Gateway::$registerAddress = $item['configs']['registerAddress'];
// @phpstan-ignore-next-line
if (isset(Gateway::$persistentConnection))
{
Gateway::$persistentConnection = false;
}
break;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Components/workerman/src/Server/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ protected function bindEvents(): void
if (isset($config['configs']['registerAddress']) && class_exists(Gateway::class))
{
Gateway::$registerAddress = $config['configs']['registerAddress'];
// @phpstan-ignore-next-line
if (isset(Gateway::$persistentConnection))
{
Gateway::$persistentConnection = false;
}
}

Event::trigger('IMI.WORKERMAN.SERVER.WORKER_START', [
Expand Down

0 comments on commit 66e6c0a

Please sign in to comment.