From 45f3b9f19fcfdf026c929a1aa29c832aca43bf43 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 10 Jun 2022 22:09:43 -0600 Subject: [PATCH] Try to stop getting "clock off" messages --- cmd/vail/main.go | 2 +- static/index.html | 3 +-- static/scripts/repeaters.mjs | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/vail/main.go b/cmd/vail/main.go index e94e0c3..257ce81 100644 --- a/cmd/vail/main.go +++ b/cmd/vail/main.go @@ -130,7 +130,7 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) { if timeDelta < 0 { timeDelta = -timeDelta } - if timeDelta > 2*time.Second { + if timeDelta > 10*time.Second { log.Println(err) ws.Close(websocket.StatusInvalidFramePayloadData, "Your clock is off by too much") break diff --git a/static/index.html b/static/index.html index bc2fa34..ea177a3 100644 --- a/static/index.html +++ b/static/index.html @@ -149,8 +149,7 @@
diff --git a/static/scripts/repeaters.mjs b/static/scripts/repeaters.mjs index fdee0d3..688c7cd 100644 --- a/static/scripts/repeaters.mjs +++ b/static/scripts/repeaters.mjs @@ -106,6 +106,9 @@ export class Vail { // and how many clients are connected if (msg.Duration.length == 0) { 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) return } @@ -134,7 +137,7 @@ export class Vail { */ Transmit(timestamp, duration, squelch=true) { let msg = { - Timestamp: timestamp, + Timestamp: timestamp - this.clockOffset, Duration: [duration], } let jmsg = JSON.stringify(msg)