pingtesterooni

canary
Bronwen 2021-04-01 22:17:43 -04:00
parent 94c9edf473
commit 94037e7de0
2 changed files with 12 additions and 4 deletions

View File

@ -74,11 +74,12 @@ class Gateway {
client.on('ready', async () => {
while(pings.length < maxPings) {
interactive.info(`[${pings.length + 1}/${maxPings}] Testing connection...`);
// pings.push(await client.ping());
pings.push(10);
await new Promise(res => setTimeout(res, 1000));
pings.push(await client.ping());
// pings.push(10);
await new Promise(res => setTimeout(res, 500));
}
interactive.success(`Test complete. Average Ping: ${pings.reduce((a, v) => a += (v / maxPings), 0)}`)
const average = Math.round(pings.reduce((a, v) => a + v, 0) / maxPings);
interactive.success(`Test complete. Average Ping: ${average}`)
client.tcpSocket.destroy();
res();
});

View File

@ -140,6 +140,13 @@ class STPSocket extends EventEmitter {
return;
}
if (this.readyState === this.SECURED && obj.cmd === 'PONG') {
if (this.pingCallbacks.has(obj.data.id)) {
this.pingCallbacks.get(obj.data.id)();
}
return;
}
}
handshake() {