mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-08-02 17:08:12 -07:00
close previous testConnect attempts (#4598)
* close previous testConnect attempts * remove onerror handler when canceling previous attempt Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
co-authored by
Jeremy Letto
parent
4899b6cfef
commit
6d200d17b7
@@ -8,6 +8,8 @@ import { SessionPersistence } from '../persistence';
|
||||
|
||||
export class WebSocketService {
|
||||
private socket: WebSocket;
|
||||
private testSocket: WebSocket;
|
||||
|
||||
private webClient: WebClient;
|
||||
private keepAliveService: KeepAliveService;
|
||||
|
||||
@@ -104,6 +106,11 @@ export class WebSocketService {
|
||||
}
|
||||
|
||||
private testWebSocket(url: string): void {
|
||||
if (this.testSocket) {
|
||||
this.testSocket.onerror = null;
|
||||
this.testSocket.close();
|
||||
}
|
||||
|
||||
const socket = new WebSocket(url);
|
||||
socket.binaryType = 'arraybuffer';
|
||||
|
||||
@@ -118,5 +125,11 @@ export class WebSocketService {
|
||||
socket.onerror = () => {
|
||||
SessionPersistence.testConnectionFailed();
|
||||
};
|
||||
|
||||
socket.onclose = () => {
|
||||
this.testSocket = null;
|
||||
}
|
||||
|
||||
this.testSocket = socket;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user