Websockets for listening to factorio logs and global chat plugin

You can now !shout things across the cluster
This commit is contained in:
Danielv123 committed 2018-04-26 18:33:29 +02:00
1 parent 641f980741
commit ce0deef83b
5 files changed
+54 -1

No files matched your search

+15 -1
View File
@@ -940,6 +940,16 @@ class wsSlave {
delete this.commandsWaitingForReturn[resp.commandID];
}
});
this.socket.on("gameChat", data => {
if(typeof data === "object"){
data.timestamp = Date.now();
if(!global.wsChatRecievers) global.wsChatRecievers = [];
global.wsChatRecievers.forEach(socket => {
socket.emit("gameChat", data);
});
}
});
}
runCommand(command, callback){
let commandID = Math.random().toString();
@@ -988,7 +998,11 @@ io.on('connection', function (socket) {
console.log("SOCKET | Created new wsSlave: "+ data.instanceID);
}
});
socket.on("registerChatReciever", function(data){
prometheusWsUsageCounter.labels("registerChatReciever").inc();
if(!global.wsChatRecievers) global.wsChatRecievers = [];
global.wsChatRecievers.push(socket);
});
});
module.exports = app;