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

View File

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

View File

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