diff --git a/umap/static/umap/js/modules/sync/engine.js b/umap/static/umap/js/modules/sync/engine.js index 9094b4822..212c2528e 100644 --- a/umap/static/umap/js/modules/sync/engine.js +++ b/umap/static/umap/js/modules/sync/engine.js @@ -61,6 +61,7 @@ export class SyncEngine { this._reconnectTimeout = null this._reconnectDelay = RECONNECT_DELAY this.websocketConnected = false + this.closeRequested = false } async authenticate() { diff --git a/umap/static/umap/js/modules/sync/websocket.js b/umap/static/umap/js/modules/sync/websocket.js index ce346ad76..26c99f26e 100644 --- a/umap/static/umap/js/modules/sync/websocket.js +++ b/umap/static/umap/js/modules/sync/websocket.js @@ -5,7 +5,6 @@ const FIRST_CONNECTION_TIMEOUT = 2000 export class WebSocketTransport { constructor(webSocketURI, authToken, messagesReceiver) { this.receiver = messagesReceiver - this.closeRequested = false this.websocket = new WebSocket(webSocketURI) @@ -16,7 +15,7 @@ export class WebSocketTransport { this.websocket.addEventListener('message', this.onMessage.bind(this)) this.websocket.onclose = () => { console.log('websocket closed') - if (!this.closeRequested) { + if (!this.receiver.closeRequested) { console.log('Not requested, reconnecting...') this.receiver.reconnect() } @@ -64,7 +63,7 @@ export class WebSocketTransport { } close() { - this.closeRequested = true + this.receiver.closeRequested = true this.websocket.close() } }