This commit is contained in:
Neale Pickett 2022-06-06 13:49:52 -06:00
parent b910676539
commit 71c108b49c
5 changed files with 12 additions and 9 deletions

View File

@ -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() {

View File

@ -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
}

View File

@ -82,7 +82,6 @@ export class Vail {
clients: msg.Clients,
connected: this.connected,
}
console.log(msg)
if (typeof(msg) == "string") {
console.error(msg)
return

View File

@ -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] {

View File

@ -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)