diff --git a/CHANGELOG.md b/CHANGELOG.md index b5128e01..117ac410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - client options specified in server config not working unless lowercased + - make disconnection detection less aggressive (don't display notification if reconnection succeeds quickly) ## 1.11.0 diff --git a/package.json b/package.json index 9470f948..b7048fea 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.11.0", + "version": "1.11.1", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" diff --git a/src/client/ipc/index.js b/src/client/ipc/index.js index 1bed84f9..870d3d5c 100644 --- a/src/client/ipc/index.js +++ b/src/client/ipc/index.js @@ -17,7 +17,7 @@ setTimeout(()=>{ locales = require('../locales') }) -var reconnectTimeout = 2000, +var reconnectTimeout = 250, hearbeatInterval = 5000, hearbeatTimeout = 3000, protocol = document.location.protocol === 'https:' ? 'wss://' : 'ws://' @@ -33,7 +33,9 @@ class Ipc extends EventEmitter { this.queue = [] this.disconnected = false - this.reconnect = undefined + + this.reconnectTimeout = undefined + this.disconnectTimeout = undefined this.hearbeat = undefined this.hearbeatTimeout = undefined @@ -93,6 +95,8 @@ class Ipc extends EventEmitter { id: 'ipc_state' }) + this.disconnected = false + this.trigger('connect') this.flush() @@ -115,18 +119,21 @@ class Ipc extends EventEmitter { clearInterval(this.hearbeat) clearTimeout(this.hearbeatTimeout) - notifications.add({ - icon: 'wifi', - class: 'error', - message: locales('server_disconnected'), - id: 'ipc_state', - duration: Infinity - }) + clearTimeout(this.disconnectTimeout) + this.disconnectTimeout = setTimeout(()=>{ + if (notifications && this.disconnected) notifications.add({ + icon: 'wifi', + class: 'error', + message: locales('server_disconnected'), + id: 'ipc_state', + duration: Infinity + }) + }, reconnectTimeout * 2) this.disconnected = true - clearTimeout(this.reconnect) - this.reconnect = setTimeout(()=>{ + clearTimeout(this.reconnectTimeout) + this.reconnectTimeout = setTimeout(()=>{ this.open() }, reconnectTimeout) diff --git a/src/client/ui/notifications.js b/src/client/ui/notifications.js index 2a5f329a..1c9547f0 100644 --- a/src/client/ui/notifications.js +++ b/src/client/ui/notifications.js @@ -18,7 +18,7 @@ class Toast { this.expires = Date.now() + (data.duration || DEFAULT_DURATION) var toast = html` -