Socket #245

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

View File

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