Factorize close command + bugfix

This commit is contained in:
Noah Zalev 2022-01-08 14:27:17 -05:00
parent fe4d426bdb
commit c51cfef7c0

View File

@ -3188,13 +3188,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}
break;
}
case 'close':
{
// Close the web socket session
if (obj.req.session && obj.req.session.ws && obj.req.session.ws == ws) { delete obj.req.session.ws; }
try { ws.close(); } catch (e) { }
break;
}
case 'getcookie':
{
// Check if this user has rights on this nodeid
@ -5190,6 +5183,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
'authcookie': serverCommandAuthCookie,
'changeemail': serverCommandChangeEmail,
'changelang': serverCommandChangeLang,
'close': serverCommandClose,
'files': serverCommandFiles,
'getnetworkinfo': serverCommandGetNetworkInfo,
'getsysinfo': serverCommandGetSysInfo,
@ -5793,6 +5787,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.parent.DispatchEvent(targets, obj, message);
}
function serverCommandClose(command) {
// Close the web socket session
try { delete obj.req.session.ws; } catch (e) { }
try { ws.close(); } catch (e) { }
}
function serverCommandFiles(command) {
// Send the full list of server files to the browser app
updateUserFiles(user, ws, domain);