reconnector: disconnect if connected.

This commit is contained in:
Miroslav Šedivý 2021-07-27 00:12:36 +02:00
parent 9f13d43da5
commit b881a52fbb
2 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,10 @@ export class WebrtcReconnector extends ReconnectorAbstract {
} }
public connect() { public connect() {
if (this._webrtc.connected) {
this._webrtc.disconnect()
}
if (this._websocket.connected) { if (this._websocket.connected) {
this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video }) this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video })
} }

View File

@ -29,6 +29,10 @@ export class WebsocketReconnector extends ReconnectorAbstract {
} }
public connect() { public connect() {
if (this._websocket.connected) {
this._websocket.disconnect()
}
let url = this._state.url let url = this._state.url
url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws' url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws'