From 71c108b49c8d55f7270a24d7397181a833ce9541 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 6 Jun 2022 13:49:52 -0600 Subject: [PATCH] Cleanup --- cmd/vail/main.go | 12 ++++++++---- static/outputs.mjs | 2 -- static/repeaters.mjs | 1 - static/vail.css | 2 ++ static/vail.mjs | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/vail/main.go b/cmd/vail/main.go index 6fcc544..3d66079 100644 --- a/cmd/vail/main.go +++ b/cmd/vail/main.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "fmt" "log" "net/http" "os" @@ -57,7 +58,6 @@ func (c *VailWebSocketConnection) Send(m Message) error { var buf []byte var messageType websocket.MessageType - log.Println("Send", m) if c.usingJSON { messageType = websocket.MessageText buf, err = json.Marshal(m) @@ -65,16 +65,17 @@ func (c *VailWebSocketConnection) Send(m Message) error { messageType = websocket.MessageBinary buf, err = m.MarshalBinary() } - log.Println(buf, err) if err != nil { return err } - log.Println("Sending") return c.Write(context.Background(), messageType, buf) } func ChatHandler(w http.ResponseWriter, r *http.Request) { + forwardedFor := r.Header.Get("X-Forwarded-For") + client := fmt.Sprintf("<%s|%s>", forwardedFor, r.RemoteAddr) + // Set up websocket ws, err := websocket.Accept( w, r, @@ -109,11 +110,12 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) { book.Join(repeaterName, &sock) defer book.Part(repeaterName, &sock) + log.Println(client, repeaterName, "connect") + for { // Read a packet m, err := sock.Receive() if err != nil { - log.Println(err) ws.Close(websocket.StatusInvalidFramePayloadData, err.Error()) break } @@ -136,6 +138,8 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) { book.Send(repeaterName, m) } + + log.Println(client, repeaterName, "disconnect") } func main() { diff --git a/static/outputs.mjs b/static/outputs.mjs index f4f251c..43f8fef 100644 --- a/static/outputs.mjs +++ b/static/outputs.mjs @@ -312,7 +312,6 @@ class LampBuzzer extends Buzzer { } SetConnected(connected) { - console.log(connected) for (let e of this.elements) { if (connected) { e.classList.add("connected") @@ -344,7 +343,6 @@ class MIDIBuzzer extends Buzzer { midiStateChange(event) { let newOutputs = new Set() for (let output of this.midiAccess.outputs.values()) { - console.log(output.state) if ((output.state != "connected") || (output.name.includes("Through"))) { continue } diff --git a/static/repeaters.mjs b/static/repeaters.mjs index a2469ef..39504ae 100644 --- a/static/repeaters.mjs +++ b/static/repeaters.mjs @@ -82,7 +82,6 @@ export class Vail { clients: msg.Clients, connected: this.connected, } - console.log(msg) if (typeof(msg) == "string") { console.error(msg) return diff --git a/static/vail.css b/static/vail.css index 1d81081..75c3b7a 100644 --- a/static/vail.css +++ b/static/vail.css @@ -22,10 +22,12 @@ } .tag.recv-lamp.connected { background-color: #fec; + color: black; } .tag.recv-lamp.rx, .tag.recv-lamp.connected.rx { background-color: orange; + color: black; } input[type=range] { diff --git a/static/vail.mjs b/static/vail.mjs index 938b7da..e407d49 100644 --- a/static/vail.mjs +++ b/static/vail.mjs @@ -281,7 +281,7 @@ class VailClient { number = Number(numberMatch[0]) } - if (name.startsWith("Fortunes")) { + if (name.startsWith("Fortunesf")) { this.roboKeyer.SetPauseMultiplier(number || 1) this.repeater = new Repeaters.Fortune(rx, this.roboKeyer) } else if (name.startsWith("Echo")) { @@ -378,7 +378,7 @@ class VailClient { if (stats.connected !== undefined) { this.outputs.SetConnected(stats.connected) } - this.updateReading("#note", stats.note || "☁") + this.updateReading("#note", stats.note || stats.clients || "😎") this.updateReading("#lag-value", averageLag) this.updateReading("#longest-rx-value", longestRxDuration) this.updateReading("#suggested-delay-value", suggestedDelay)