From bc45aaaf3a0736df5c396330301d4c5e3fc045a5 Mon Sep 17 00:00:00 2001 From: Matheus Sampaio Queiroga Date: Mon, 22 Nov 2021 18:35:44 -0300 Subject: [PATCH] Update BdsManegerServer.js --- src/BdsManegerServer.js | 46 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/BdsManegerServer.js b/src/BdsManegerServer.js index 2a4f1a8..27c50a3 100644 --- a/src/BdsManegerServer.js +++ b/src/BdsManegerServer.js @@ -290,33 +290,31 @@ module.exports.StartServer = function start() { }); // Socket.io - io.on("connection", (socket) => { - socket.on("ServerCommand", (data = "") => { - if (typeof data === "string") return returnFuntion.command(data); - else if (typeof data === "object") { - if (typeof data.uuid === "string") { - if (data.uuid === returnFuntion.uuid) return returnFuntion.command(data.command); - } + io.on("ServerCommand", (data = "") => { + if (typeof data === "string") return returnFuntion.command(data); + else if (typeof data === "object") { + if (typeof data.uuid === "string") { + if (data.uuid === returnFuntion.uuid) return returnFuntion.command(data.command); } - return; - }); - ServerExec.on("exit", code => socket.emit("ServerExit", { + } + return; + }); + ServerExec.on("exit", code => io.emit("ServerExit", { + UUID: returnFuntion.uuid, + exitCode: code + })); + ServerExec.stdout.on("data", (data = "") => { + io.emit("ServerLog", { UUID: returnFuntion.uuid, - exitCode: code - })); - ServerExec.stdout.on("data", (data = "") => { - socket.emit("ServerLog", { - UUID: returnFuntion.uuid, - data: data, - IsStderr: false - }); + data: data, + IsStderr: false }); - ServerExec.stderr.on("data", (data = "") => { - socket.emit("ServerLog", { - UUID: returnFuntion.uuid, - data: data, - IsStderr: true - }); + }); + ServerExec.stderr.on("data", (data = "") => { + io.emit("ServerLog", { + UUID: returnFuntion.uuid, + data: data, + IsStderr: true }); }); -- 2.49.0