Clock off adjust + Prominent repeater name

Fixes #14 (I hope)
This commit is contained in:
Neale Pickett 2020-06-01 19:55:28 -06:00
parent 5460c9e3c9
commit 0730dde2a2
3 changed files with 16 additions and 7 deletions

View File

@ -59,7 +59,10 @@
<div class="flex">
<div class="mdl-card mdl-shadow--4dp input-methods">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Input</h2>
<h2 class="mdl-card__title-text">
<span id="repeater"></span>
Repeater
</h2>
<div id="recv">
<!-- This div appears as a little light that turns on when someone's sending -->
<i class="material-icons" id="muted">volume_off</i>
@ -370,10 +373,10 @@
</tr>
<tr>
<td>
Repeater:
Your clock is off by:
</td>
<td>
<span id="repeater"></span>
<output id="clock-off-value">??</output>ms
</td>
</tr>
</tbody>

View File

@ -101,6 +101,11 @@ img {
max-height: inherit;
}
#repeater {
font-style: italic;
margin-right: 0.3em;
}
#recv {
width: 3em;
height: 2em;

View File

@ -291,7 +291,7 @@ class Vail {
this.sent = []
this.lagTimes = [0]
this.rxDurations = [0]
this.clockOffset = null // How badly our clock is off of the server's
this.clockOffset = 0 // How badly our clock is off of the server's
this.rxDelay = 0 // Milliseconds to add to incoming timestamps
this.beginTxTime = null // Time when we began transmitting
@ -440,6 +440,7 @@ class Vail {
this.updateReading("#lag-value", avgLag.toFixed())
this.updateReading("#longest-rx-value", longestRx)
this.updateReading("#suggested-delay-value", suggestedDelay.toFixed())
this.updateReading("#clock-off-value", this.clockOffset)
}
addLagReading(duration) {
@ -459,7 +460,7 @@ class Vail {
}
wsSend(time, duration) {
let msg = [time, duration]
let msg = [time + this.clockOffset, duration]
let jmsg = JSON.stringify(msg)
this.socket.send(jmsg)
this.sent.push(jmsg)
@ -482,9 +483,9 @@ class Vail {
// Server is telling us the current time
if (durations.length == 0) {
let offset = now - beginTxTime
console.log("Our clock ahead of server by", offset, "ms")
if (this.clockOffset === null) {
if (this.clockOffset == 0) {
this.clockOffset = offset
this.updateReadings()
}
return
}