diff --git a/src/component/internal/connection.ts b/src/component/internal/connection.ts index 256e5a70..2860185b 100644 --- a/src/component/internal/connection.ts +++ b/src/component/internal/connection.ts @@ -201,18 +201,19 @@ export class NekoConnection extends EventEmitter { public close(error?: Error) { if (this._open) { - this._open = false - // set state to disconnected Vue.set(this._state.websocket, 'connected', false) Vue.set(this._state.webrtc, 'connected', false) Vue.set(this._state, 'status', 'disconnected') - - this.emit('close', error) } // close all reconnectors Object.values(this._reconnector).forEach((r) => r.close()) + + if (this._open) { + this._open = false + this.emit('close', error) + } } public destroy() {