From eeec905df0e0b4a91b49ebc61224ca8507992334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 16 Nov 2024 20:21:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=8D=E5=90=91ws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/network/active-websocket.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/onebot/network/active-websocket.ts b/src/onebot/network/active-websocket.ts index b68cd51c..ce2a1130 100644 --- a/src/onebot/network/active-websocket.ts +++ b/src/onebot/network/active-websocket.ts @@ -43,7 +43,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } }, this.config.heartInterval); } - + this.isEnable = true; await this.tryConnect(); } @@ -70,7 +70,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } private async tryConnect() { - if (!this.connection && !this.isEnable) { + if (!this.connection && this.isEnable) { let isClosedByError = false; this.connection = new WebSocket(this.config.url, { @@ -106,7 +106,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { if (!isClosedByError) { this.logger.logError.bind(this.logger)(`[OneBot] [WebSocket Client] 反向WebSocket (${this.config.url}) 连接意外关闭`); this.logger.logError.bind(this.logger)(`[OneBot] [WebSocket Client] 在 ${Math.floor(this.config.reconnectInterval / 1000)} 秒后尝试重新连接`); - if (!this.isEnable) { + if (this.isEnable) { this.connection = null; setTimeout(() => this.tryConnect(), this.config.reconnectInterval); } @@ -116,7 +116,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { isClosedByError = true; this.logger.logError.bind(this.logger)(`[OneBot] [WebSocket Client] 反向WebSocket (${this.config.url}) 连接错误`, err); this.logger.logError.bind(this.logger)(`[OneBot] [WebSocket Client] 在 ${Math.floor(this.config.reconnectInterval / 1000)} 秒后尝试重新连接`); - if (!this.isEnable) { + if (this.isEnable) { this.connection = null; setTimeout(() => this.tryConnect(), this.config.reconnectInterval); }