Fix rare error with ws.close()

This commit is contained in:
Alexey Khit
2023-08-04 16:31:13 +04:00
parent 9c5ae3260c
commit 4baa3f5588
+8 -4
View File
@@ -551,12 +551,16 @@ export class VideoRTC extends HTMLElement {
this.pcState = WebSocket.OPEN;
this.wsState = WebSocket.CLOSED;
this.ws.close();
this.ws = null;
if (this.ws) {
this.ws.close();
this.ws = null;
}
} else {
this.pcState = WebSocket.CLOSED;
this.pc.close();
this.pc = null;
if (this.pc) {
this.pc.close();
this.pc = null;
}
}
}