Update to master to support server wide alerts

This commit is contained in:
Danielv123 committed 2018-04-27 21:23:36 +02:00
1 parent 84aaae05c2
commit dc19457471
1 file changed
+15
+15
View File
@@ -950,6 +950,16 @@ class wsSlave {
});
}
});
this.socket.on("alert", alert => {
if(typeof alert === "object"){
alert.timestamp = Date.now();
if(!global.wsAlertRecievers) global.wsAlertRecievers = [];
global.wsAlertRecievers.forEach(socket => {
socket.emit("alert", alert);
});
}
});
}
runCommand(command, callback){
let commandID = Math.random().toString();
@@ -1003,6 +1013,11 @@ io.on('connection', function (socket) {
if(!global.wsChatRecievers) global.wsChatRecievers = [];
global.wsChatRecievers.push(socket);
});
socket.on("registerAlertReciever", function(data){
prometheusWsUsageCounter.labels("registerAlertReciever").inc();
if(!global.wsAlertRecievers) global.wsAlertRecievers = [];
global.wsAlertRecievers.push(socket);
}
});
module.exports = app;