mirror of https://github.com/nealey/vail.git
Try to stop getting "clock off" messages
This commit is contained in:
parent
460cb75e5b
commit
45f3b9f19f
|
@ -130,7 +130,7 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if timeDelta < 0 {
|
if timeDelta < 0 {
|
||||||
timeDelta = -timeDelta
|
timeDelta = -timeDelta
|
||||||
}
|
}
|
||||||
if timeDelta > 2*time.Second {
|
if timeDelta > 10*time.Second {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
ws.Close(websocket.StatusInvalidFramePayloadData, "Your clock is off by too much")
|
ws.Close(websocket.StatusInvalidFramePayloadData, "Your clock is off by too much")
|
||||||
break
|
break
|
||||||
|
|
|
@ -149,8 +149,7 @@
|
||||||
<div class="field is-horizontal">
|
<div class="field is-horizontal">
|
||||||
<div class="field-label">
|
<div class="field-label">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<output for="keyer-rate"></output>
|
<output for="keyer-rate"></output> <span data-i18n="label.wpm">WPM</span>
|
||||||
<span data-i18n="label.wpm">WPM</span>
|
|
||||||
/
|
/
|
||||||
<span data-fill="keyer-ms"></span><span data-i18n="label:ms">ms</span>
|
<span data-fill="keyer-ms"></span><span data-i18n="label:ms">ms</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -106,6 +106,9 @@ export class Vail {
|
||||||
// and how many clients are connected
|
// and how many clients are connected
|
||||||
if (msg.Duration.length == 0) {
|
if (msg.Duration.length == 0) {
|
||||||
this.clockOffset = now - msg.Timestamp
|
this.clockOffset = now - msg.Timestamp
|
||||||
|
console.log("them:", msg.Timestamp)
|
||||||
|
console.log(" us:", now)
|
||||||
|
console.log("Clock offset", this.clockOffset)
|
||||||
this.rx(0, 0, stats)
|
this.rx(0, 0, stats)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -134,7 +137,7 @@ export class Vail {
|
||||||
*/
|
*/
|
||||||
Transmit(timestamp, duration, squelch=true) {
|
Transmit(timestamp, duration, squelch=true) {
|
||||||
let msg = {
|
let msg = {
|
||||||
Timestamp: timestamp,
|
Timestamp: timestamp - this.clockOffset,
|
||||||
Duration: [duration],
|
Duration: [duration],
|
||||||
}
|
}
|
||||||
let jmsg = JSON.stringify(msg)
|
let jmsg = JSON.stringify(msg)
|
||||||
|
|
Loading…
Reference in New Issue