Factorize close command + bugfix
Noah Zalev committed
Jan 8, 2022 at 14:27 UTC
c51cfef7c0751804a736aa0e0a80b3ad2905c9bb
1 file changed
+7
-7
meshuser.js
+7
-7
@@ -3188,13 +3188,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3188
}
3189
break;
3190
}
3191
- case 'close':
3192
- {
3193
- // Close the web socket session
3194
- if (obj.req.session && obj.req.session.ws && obj.req.session.ws == ws) { delete obj.req.session.ws; }
3195
- try { ws.close(); } catch (e) { }
3196
- break;
3197
- }
3191
case 'getcookie':
3192
{
3193
// Check if this user has rights on this nodeid
@@ -5190,6 +5183,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5183
'authcookie': serverCommandAuthCookie,
5184
'changeemail': serverCommandChangeEmail,
5185
'changelang': serverCommandChangeLang,
5186
+ 'close': serverCommandClose,
5187
'files': serverCommandFiles,
5188
'getnetworkinfo': serverCommandGetNetworkInfo,
5189
'getsysinfo': serverCommandGetSysInfo,
@@ -5793,6 +5787,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5787
parent.parent.DispatchEvent(targets, obj, message);
5788
}
5789
5790
+ function serverCommandClose(command) {
5791
+ // Close the web socket session
5792
+ try { delete obj.req.session.ws; } catch (e) { }
5793
+ try { ws.close(); } catch (e) { }
5794
+ }
5795
+
5796
function serverCommandFiles(command) {
5797
// Send the full list of server files to the browser app
5798
updateUserFiles(user, ws, domain);