Skip to content

Commit

Permalink
🐛 修复部分情况下连接断开后不会重连的问题 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-kirami authored Dec 3, 2024
1 parent 5875145 commit 5cd6e24
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/driver/websocket-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export class websocketClient implements Driver {
const request = (message.type === 'Text' ? JSON.parse(message.data) : decode(message.data)) as ActionRequest
const response = { ...(await this.adapter.actionHandle(request)), echo: request.echo }
const data

= message.type === 'Text' ? JSON.stringify(response, this.adapter.JSONEncode) : [...encode(response)]
await this.ws?.send(data)
break
Expand All @@ -119,7 +118,13 @@ export class websocketClient implements Driver {
this.autoReconnection()
break
}
// no default
default: {
await this.disconnect()
toast.error('连接错误', { description: 'WebSocket 服务器出现意外错误' })
void logger.error(`[WebSocket] 反向 WebSocket 服务器 ${this.connectUrl} 出现意外错误: ${message}`)
this.autoReconnection()
break
}
}
}

Expand Down

0 comments on commit 5cd6e24

Please sign in to comment.