Show only QSOs 10min. or younger
This commit is contained in:
15
mqtt.js
15
mqtt.js
@@ -42,11 +42,18 @@ mqttC.on('message', function (topic, message) { // Handler, wenn mqtt-message ko
|
|||||||
}
|
}
|
||||||
if (topic.startsWith('wavelog/qso/logged')) {
|
if (topic.startsWith('wavelog/qso/logged')) {
|
||||||
tobrowser=parse_qso_msg(msg.content);
|
tobrowser=parse_qso_msg(msg.content);
|
||||||
io.emit("mqtt",tobrowser); // und raus an den Browser damit
|
if (tobrowser.qso_time) {
|
||||||
|
tobrowser.qso_age=dinmin(tobrowser.qso_time);
|
||||||
|
if (tobrowser.qso_age<=10) {
|
||||||
|
io.emit("mqtt",tobrowser); // und raus an den Browser (nur fuer DIESES Socket, nicht fuer alle Clients) damit
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("No Timestamp!");
|
||||||
|
}
|
||||||
console.log(topic+' / QSO from: '+tobrowser.station_call+' with '+tobrowser.call+' in Mode: '+tobrowser.mode+' at '+tobrowser.qso_time);
|
console.log(topic+' / QSO from: '+tobrowser.station_call+' with '+tobrowser.call+' in Mode: '+tobrowser.mode+' at '+tobrowser.qso_time);
|
||||||
} else {
|
} else {
|
||||||
tobrowser=parse_cat_msg(topic,msg.content);
|
tobrowser=parse_cat_msg(topic,msg.content);
|
||||||
io.emit("cat",tobrowser); // und raus an den Browser damit
|
// io.emit("cat",tobrowser); // und raus an den Browser (nur fuer DIESES Socket, nicht fuer alle Clients) damit
|
||||||
console.log(topic+' / CAT for User '+tobrowser.user_id+' at '+tobrowser.qrg+' in Mode '+tobrowser.mode);
|
console.log(topic+' / CAT for User '+tobrowser.user_id+' at '+tobrowser.qrg+' in Mode '+tobrowser.mode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -83,6 +90,10 @@ function parse_qso_msg(msg) {
|
|||||||
return retmsg;
|
return retmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dinmin = (timestamp) => {
|
||||||
|
return Math.floor((Date.now() - new Date(timestamp).getTime()) / 60000);
|
||||||
|
}
|
||||||
|
|
||||||
http.listen(8000,'127.0.0.1', () => { // Webserver starten
|
http.listen(8000,'127.0.0.1', () => { // Webserver starten
|
||||||
console.log(`Socket.IO server running at http://localhost:8000/`); // debug
|
console.log(`Socket.IO server running at http://localhost:8000/`); // debug
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user