KASM-7180 ensure UI.rfb is defined (#133)

Co-authored-by: Matt McClaskey <matt@kasmweb.com>
This commit is contained in:
Matt McClaskey 2025-04-16 05:52:13 -04:00 committed by GitHub
parent 5d468a3fe1
commit 14c8c2af59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 11 deletions

View File

@ -1551,18 +1551,19 @@ const UI = {
//keep alive for websocket connection to stay open, since we may not control reverse proxies //keep alive for websocket connection to stay open, since we may not control reverse proxies
//send a keep alive within a window that we control //send a keep alive within a window that we control
UI._sessionTimeoutInterval = setInterval(function() { UI._sessionTimeoutInterval = setInterval(function() {
if (UI.rfb) {
const timeSinceLastActivityInS = (Date.now() - UI.rfb.lastActiveAt) / 1000;
let idleDisconnectInS = 1200; //20 minute default
if (Number.isFinite(parseFloat(UI.rfb.idleDisconnect))) {
idleDisconnectInS = parseFloat(UI.rfb.idleDisconnect) * 60;
}
const timeSinceLastActivityInS = (Date.now() - UI.rfb.lastActiveAt) / 1000; if (timeSinceLastActivityInS > idleDisconnectInS) {
let idleDisconnectInS = 1200; //20 minute default parent.postMessage({ action: 'idle_session_timeout', value: 'Idle session timeout exceeded'}, '*' );
if (Number.isFinite(parseFloat(UI.rfb.idleDisconnect))) { } else {
idleDisconnectInS = parseFloat(UI.rfb.idleDisconnect) * 60; //send keep-alive
} UI.rfb.sendKey(1, null, false);
}
if (timeSinceLastActivityInS > idleDisconnectInS) {
parent.postMessage({ action: 'idle_session_timeout', value: 'Idle session timeout exceeded'}, '*' );
} else {
//send keep-alive
UI.rfb.sendKey(1, null, false);
} }
}, 5000); }, 5000);
} else { } else {