From 66e6c0ae436521683b75c38203269fe9a9369467 Mon Sep 17 00:00:00 2001 From: Yurun Date: Wed, 8 Feb 2023 19:00:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Workerman=20Gateway=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=20(#469)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复 Workerman Gateway 兼容性 * 修复测试 --- .../workerman-gateway/src/Swoole/Listener/AppRunListener.php | 5 +++++ .../src/Swoole/Server/Business/TcpBusinessServer.php | 5 +++++ .../src/Swoole/Server/Business/WebSocketBusinessServer.php | 5 +++++ .../src/Workerman/Listener/AppRunListener.php | 5 +++++ src/Components/workerman/src/Server/Base.php | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/src/Components/workerman-gateway/src/Swoole/Listener/AppRunListener.php b/src/Components/workerman-gateway/src/Swoole/Listener/AppRunListener.php index 1da1ce68f1..17fd5af125 100644 --- a/src/Components/workerman-gateway/src/Swoole/Listener/AppRunListener.php +++ b/src/Components/workerman-gateway/src/Swoole/Listener/AppRunListener.php @@ -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; + } } } } diff --git a/src/Components/workerman-gateway/src/Swoole/Server/Business/TcpBusinessServer.php b/src/Components/workerman-gateway/src/Swoole/Server/Business/TcpBusinessServer.php index b40690c246..be65a24eeb 100644 --- a/src/Components/workerman-gateway/src/Swoole/Server/Business/TcpBusinessServer.php +++ b/src/Components/workerman-gateway/src/Swoole/Server/Business/TcpBusinessServer.php @@ -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) { diff --git a/src/Components/workerman-gateway/src/Swoole/Server/Business/WebSocketBusinessServer.php b/src/Components/workerman-gateway/src/Swoole/Server/Business/WebSocketBusinessServer.php index 73ee08ad20..a11a834b1c 100644 --- a/src/Components/workerman-gateway/src/Swoole/Server/Business/WebSocketBusinessServer.php +++ b/src/Components/workerman-gateway/src/Swoole/Server/Business/WebSocketBusinessServer.php @@ -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) { diff --git a/src/Components/workerman-gateway/src/Workerman/Listener/AppRunListener.php b/src/Components/workerman-gateway/src/Workerman/Listener/AppRunListener.php index 4979e627bf..d378527cdf 100644 --- a/src/Components/workerman-gateway/src/Workerman/Listener/AppRunListener.php +++ b/src/Components/workerman-gateway/src/Workerman/Listener/AppRunListener.php @@ -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; } } diff --git a/src/Components/workerman/src/Server/Base.php b/src/Components/workerman/src/Server/Base.php index 37bed9196c..7f4b2035ac 100644 --- a/src/Components/workerman/src/Server/Base.php +++ b/src/Components/workerman/src/Server/Base.php @@ -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', [