|
|
@ -19,15 +19,16 @@ module.exports = class TermConnection extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
this.pageShown = false |
|
|
|
this.pageShown = false |
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('focus', () => { |
|
|
|
document.addEventListener('visibilitychange', () => { |
|
|
|
console.info('Window got focus, re-connecting') |
|
|
|
if (document.hidden === true) { |
|
|
|
this.init() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
window.addEventListener('blur', () => { |
|
|
|
|
|
|
|
console.info('Window lost focus, freeing socket') |
|
|
|
console.info('Window lost focus, freeing socket') |
|
|
|
this.closeSocket() |
|
|
|
this.closeSocket() |
|
|
|
clearTimeout(this.heartbeatTimeout) |
|
|
|
clearTimeout(this.heartbeatTimeout) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
|
|
|
|
console.info('Window got focus, re-connecting') |
|
|
|
|
|
|
|
this.init() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onWSOpen (evt) { |
|
|
|
onWSOpen (evt) { |
|
|
|