Socket #245

Merged
Sirherobrine23 merged 1 commits from Socket into main 2021-11-22 21:54:41 +00:00

@ -290,8 +290,7 @@ module.exports.StartServer = function start() {
});
// Socket.io
io.on("connection", (socket) => {
socket.on("ServerCommand", (data = "") => {
io.on("ServerCommand", (data = "") => {
if (typeof data === "string") return returnFuntion.command(data);
else if (typeof data === "object") {
if (typeof data.uuid === "string") {
@ -300,25 +299,24 @@ module.exports.StartServer = function start() {
}
return;
});
ServerExec.on("exit", code => socket.emit("ServerExit", {
ServerExec.on("exit", code => io.emit("ServerExit", {
UUID: returnFuntion.uuid,
exitCode: code
}));
ServerExec.stdout.on("data", (data = "") => {
socket.emit("ServerLog", {
io.emit("ServerLog", {
UUID: returnFuntion.uuid,
data: data,
IsStderr: false
});
});
ServerExec.stderr.on("data", (data = "") => {
socket.emit("ServerLog", {
io.emit("ServerLog", {
UUID: returnFuntion.uuid,
data: data,
IsStderr: true
});
});
});
// Return
ServerSessions[returnFuntion.uuid] = returnFuntion;