emit close event after closing all reconnectors.

This commit is contained in:
Miroslav Šedivý 2022-08-17 21:08:34 +02:00
parent 9a77f6adea
commit ac6df17036

View File

@ -201,18 +201,19 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
public close(error?: Error) { public close(error?: Error) {
if (this._open) { if (this._open) {
this._open = false
// set state to disconnected // set state to disconnected
Vue.set(this._state.websocket, 'connected', false) Vue.set(this._state.websocket, 'connected', false)
Vue.set(this._state.webrtc, 'connected', false) Vue.set(this._state.webrtc, 'connected', false)
Vue.set(this._state, 'status', 'disconnected') Vue.set(this._state, 'status', 'disconnected')
this.emit('close', error)
} }
// close all reconnectors // close all reconnectors
Object.values(this._reconnector).forEach((r) => r.close()) Object.values(this._reconnector).forEach((r) => r.close())
if (this._open) {
this._open = false
this.emit('close', error)
}
} }
public destroy() { public destroy() {