Socket #245

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

View File

@ -290,33 +290,31 @@ 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") { if (data.uuid === returnFuntion.uuid) return returnFuntion.command(data.command);
if (data.uuid === returnFuntion.uuid) return returnFuntion.command(data.command);
}
} }
return; }
}); 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 = "") => {
io.emit("ServerLog", {
UUID: returnFuntion.uuid, UUID: returnFuntion.uuid,
exitCode: code data: data,
})); IsStderr: false
ServerExec.stdout.on("data", (data = "") => {
socket.emit("ServerLog", {
UUID: returnFuntion.uuid,
data: data,
IsStderr: false
});
}); });
ServerExec.stderr.on("data", (data = "") => { });
socket.emit("ServerLog", { ServerExec.stderr.on("data", (data = "") => {
UUID: returnFuntion.uuid, io.emit("ServerLog", {
data: data, UUID: returnFuntion.uuid,
IsStderr: true data: data,
}); IsStderr: true
}); });
}); });