From b689733d59139f158de95b0017865c867d0c7159 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 24 Nov 2023 16:37:52 +0800 Subject: [PATCH] Fix getGameList, testChrome without checkLogin --- .../socket-handlers/general-socket-handler.js | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/server/socket-handlers/general-socket-handler.js b/server/socket-handlers/general-socket-handler.js index 2f0c63b41..c7f77b65b 100644 --- a/server/socket-handlers/general-socket-handler.js +++ b/server/socket-handlers/general-socket-handler.js @@ -42,24 +42,40 @@ module.exports.generalSocketHandler = (socket, server) => { }); socket.on("getGameList", async (callback) => { - callback({ - ok: true, - gameList: getGameList(), - }); - }); - - socket.on("testChrome", (executable, callback) => { - // Just noticed that await call could block the whole socket.io server!!! Use pure promise instead. - testChrome(executable).then((version) => { + try { + checkLogin(socket); callback({ ok: true, - msg: "Found Chromium/Chrome. Version: " + version, + gameList: getGameList(), }); - }).catch((e) => { + } catch (e) { callback({ ok: false, msg: e.message, + }) + } + }); + + socket.on("testChrome", (executable, callback) => { + try { + checkLogin(socket); + // Just noticed that await call could block the whole socket.io server!!! Use pure promise instead. + testChrome(executable).then((version) => { + callback({ + ok: true, + msg: "Found Chromium/Chrome. Version: " + version, + }); + }).catch((e) => { + callback({ + ok: false, + msg: e.message, + }); }); - }); + } catch (e) { + callback({ + ok: false, + msg: e.message, + }) + } }); };