Fix issue where the center thought it still had live connections when a connection died

This commit is contained in:
David Majdandžić
2023-03-27 16:39:15 +02:00
parent 21d0e515e8
commit 96b0257c1d
2 changed files with 64 additions and 42 deletions

View File

@@ -3,7 +3,10 @@ const WebSocket = require('ws');
const WS_SERVER_PORT = process.env.WS_SERVER_PORT || 8191;
class Metrics {
static interestingMetrics = ['submit_sm', 'deliver_sm'];
static interestingMetrics = [
'submit_sm',
'deliver_sm'
];
metrics = {};
constructor() {
@@ -31,13 +34,11 @@ let centerMetrics = new Metrics();
const ws = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
ws.on('open', () => {
console.log('WebSocket connection established');
ws.send("client:0");
ws.send("client:1");
});
ws.on('message', (data) => {
data = JSON.parse(data);
if (data.type === 'pdu') {
clientMetrics.processPdu(data.value);
}
console.log(data);
});
const ws2 = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
@@ -47,13 +48,14 @@ ws2.on('open', () => {
});
ws2.on('message', (data) => {
data = JSON.parse(data);
if (data.type === 'pdu') {
centerMetrics.processPdu(data.value);
}
console.log(data);
// if (data.type === 'pdu') {
// centerMetrics.processPdu(data.value);
// }
});
setInterval(() => {
console.log(clientMetrics.metrics);
console.log(centerMetrics.metrics);
console.log("");
}, 500);
// setInterval(() => {
// console.log(clientMetrics.metrics);
// // console.log(centerMetrics.metrics);
// console.log("");
// }, 500);