fix: 修复重连问题

This commit is contained in:
song_xiao_lin
2024-05-15 14:43:04 +08:00
committed by go0p
parent ac36e0bfc7
commit 289dcdf030
3 changed files with 34 additions and 20 deletions
+3 -3
View File
@@ -13,12 +13,12 @@ export class WebSocketManager {
this.intervalId = null;
}
connectWebsocket(url) {
connectWebsocket(url, port) {
this.disconnectWebsocket();
this.socket = new WebSocket(url);
this.socket.onopen = () => {
chrome.runtime.sendMessage({action: ActionType.STATUS, connected: true});
chrome.runtime.sendMessage({action: ActionType.STATUS, connected: true, port: port});
this.startHeartbeat();
};
@@ -27,7 +27,7 @@ export class WebSocketManager {
};
this.socket.onclose = () => {
chrome.runtime.sendMessage({action: ActionType.STATUS, connected: false});
chrome.runtime.sendMessage({action: ActionType.STATUS, connected: false, port: port});
};
this.socket.onerror = (error) => {