disconnect sessions first before logout on idletimeout (#5838)

Signed-off-by: si458 <simonsmith5521@gmail.com>

Simon Smith committed Feb 20, 2024 at 21:59 UTC 936aaa0b2bb89e54411cdb03c4efe710daf5160a
1 file changed +17 -1
views/default.handlebars
+17 -1
@@ -2330,7 +2330,23 @@
2330 function setSessionActivity() { sessionActivity = Date.now(); QH('idleTimeoutNotify', ''); }
2331 function checkIdleSessionTimeout() {
2332 var delta = (Date.now() - sessionActivity);
2333 - if (delta > serverinfo.timeout) { window.location.href = 'logout'; } else {
2333 + if (delta > serverinfo.timeout) {
2334 + if (desktop != null) { // Disconnect remote desktop
2335 + desktop.Stop();
2336 + webRtcDesktopReset();
2337 + desktopNode = desktop = null;
2338 + if (pluginHandler != null) { pluginHandler.callHook('onDesktopDisconnect'); }
2339 + }
2340 + if (terminal != null) { // Disconnect terminal
2341 + terminal.Stop();
2342 + terminal = null;
2343 + }
2344 + if (files != null) { // Disconnect files
2345 + files.Stop();
2346 + files = null;
2347 + }
2348 + window.location.href = 'logout';
2349 + } else {
2350 var ds = Math.round((serverinfo.timeout - delta) / 1000);
2351 if (ds <= 60) {
2352 QH('idleTimeoutNotify', '<br />' + format((ds == 1)?"1 second until disconnect":"{0} seconds until disconnect", ds));