From 44a8c8e35d98e7bce1baa33d14af6019bb972716 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: Sun, 11 Aug 2024 00:24:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20network=20=E5=88=9D=E6=AD=A5=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/network/active-websocket.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/onebot/network/active-websocket.ts b/src/onebot/network/active-websocket.ts index a3437a00..d394c0db 100644 --- a/src/onebot/network/active-websocket.ts +++ b/src/onebot/network/active-websocket.ts @@ -26,7 +26,6 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } registerHeartBeat() { - // WS反向心跳 if (this.connection) { this.heartbeatTimer = setInterval(() => { if (this.connection && this.connection.readyState === NodeWebSocket.OPEN) { @@ -42,8 +41,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { onEvent(event: T) { if (this.connection) { - const wrappedEvent = this.wrapEvent(event); - this.connection.send(JSON.stringify(wrappedEvent)); + this.connection.send(JSON.stringify(event)); } } @@ -70,7 +68,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } private async tryConnect() { - while (!this.connection) { + while (!this.connection && !this.isClosed) { try { this.connection = new NodeWebSocket(this.url); this.connection.on('message', (data) => { @@ -102,12 +100,4 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { console.error('Failed to handle message:', e); } } - - private wrapEvent(event: T) { - // Wrap the event as needed - return { - type: 'event', - data: event - }; - } } \ No newline at end of file