Improve readability
This commit is contained in:
parent
14453a43f9
commit
0adab1c9c4
@ -110,6 +110,8 @@ const addConnectionStatus = (level, type, value) => {
|
|||||||
let rttCalcStartedAt = 0;
|
let rttCalcStartedAt = 0;
|
||||||
|
|
||||||
const fetchRoundTripTime = () => {
|
const fetchRoundTripTime = () => {
|
||||||
|
// if client didn't receive response from last "voidConnection"
|
||||||
|
// calculate the rtt from last call time and notify user of connection loss
|
||||||
if (rttCalcStartedAt !== 0) {
|
if (rttCalcStartedAt !== 0) {
|
||||||
const tf = Date.now();
|
const tf = Date.now();
|
||||||
const rtt = tf - rttCalcStartedAt;
|
const rtt = tf - rttCalcStartedAt;
|
||||||
@ -118,8 +120,6 @@ const fetchRoundTripTime = () => {
|
|||||||
const event = new CustomEvent('socketstats', { detail: { rtt } });
|
const event = new CustomEvent('socketstats', { detail: { rtt } });
|
||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
rttCalcStartedAt = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const t0 = Date.now();
|
const t0 = Date.now();
|
||||||
@ -132,9 +132,7 @@ const fetchRoundTripTime = () => {
|
|||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
lastRtt = rtt;
|
lastRtt = rtt;
|
||||||
|
|
||||||
if (rttCalcStartedAt === t0) {
|
rttCalcStartedAt = 0;
|
||||||
rttCalcStartedAt = 0;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user