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