mirror of https://github.com/nealey/vail.git
Cleanup
This commit is contained in:
parent
b910676539
commit
71c108b49c
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -57,7 +58,6 @@ func (c *VailWebSocketConnection) Send(m Message) error {
|
||||||
var buf []byte
|
var buf []byte
|
||||||
var messageType websocket.MessageType
|
var messageType websocket.MessageType
|
||||||
|
|
||||||
log.Println("Send", m)
|
|
||||||
if c.usingJSON {
|
if c.usingJSON {
|
||||||
messageType = websocket.MessageText
|
messageType = websocket.MessageText
|
||||||
buf, err = json.Marshal(m)
|
buf, err = json.Marshal(m)
|
||||||
|
@ -65,16 +65,17 @@ func (c *VailWebSocketConnection) Send(m Message) error {
|
||||||
messageType = websocket.MessageBinary
|
messageType = websocket.MessageBinary
|
||||||
buf, err = m.MarshalBinary()
|
buf, err = m.MarshalBinary()
|
||||||
}
|
}
|
||||||
log.Println(buf, err)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Sending")
|
|
||||||
return c.Write(context.Background(), messageType, buf)
|
return c.Write(context.Background(), messageType, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChatHandler(w http.ResponseWriter, r *http.Request) {
|
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
|
// Set up websocket
|
||||||
ws, err := websocket.Accept(
|
ws, err := websocket.Accept(
|
||||||
w, r,
|
w, r,
|
||||||
|
@ -109,11 +110,12 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
book.Join(repeaterName, &sock)
|
book.Join(repeaterName, &sock)
|
||||||
defer book.Part(repeaterName, &sock)
|
defer book.Part(repeaterName, &sock)
|
||||||
|
|
||||||
|
log.Println(client, repeaterName, "connect")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Read a packet
|
// Read a packet
|
||||||
m, err := sock.Receive()
|
m, err := sock.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
|
||||||
ws.Close(websocket.StatusInvalidFramePayloadData, err.Error())
|
ws.Close(websocket.StatusInvalidFramePayloadData, err.Error())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -136,6 +138,8 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
book.Send(repeaterName, m)
|
book.Send(repeaterName, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println(client, repeaterName, "disconnect")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -312,7 +312,6 @@ class LampBuzzer extends Buzzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConnected(connected) {
|
SetConnected(connected) {
|
||||||
console.log(connected)
|
|
||||||
for (let e of this.elements) {
|
for (let e of this.elements) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
e.classList.add("connected")
|
e.classList.add("connected")
|
||||||
|
@ -344,7 +343,6 @@ class MIDIBuzzer extends Buzzer {
|
||||||
midiStateChange(event) {
|
midiStateChange(event) {
|
||||||
let newOutputs = new Set()
|
let newOutputs = new Set()
|
||||||
for (let output of this.midiAccess.outputs.values()) {
|
for (let output of this.midiAccess.outputs.values()) {
|
||||||
console.log(output.state)
|
|
||||||
if ((output.state != "connected") || (output.name.includes("Through"))) {
|
if ((output.state != "connected") || (output.name.includes("Through"))) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,6 @@ export class Vail {
|
||||||
clients: msg.Clients,
|
clients: msg.Clients,
|
||||||
connected: this.connected,
|
connected: this.connected,
|
||||||
}
|
}
|
||||||
console.log(msg)
|
|
||||||
if (typeof(msg) == "string") {
|
if (typeof(msg) == "string") {
|
||||||
console.error(msg)
|
console.error(msg)
|
||||||
return
|
return
|
||||||
|
|
|
@ -22,10 +22,12 @@
|
||||||
}
|
}
|
||||||
.tag.recv-lamp.connected {
|
.tag.recv-lamp.connected {
|
||||||
background-color: #fec;
|
background-color: #fec;
|
||||||
|
color: black;
|
||||||
}
|
}
|
||||||
.tag.recv-lamp.rx,
|
.tag.recv-lamp.rx,
|
||||||
.tag.recv-lamp.connected.rx {
|
.tag.recv-lamp.connected.rx {
|
||||||
background-color: orange;
|
background-color: orange;
|
||||||
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=range] {
|
input[type=range] {
|
||||||
|
|
|
@ -281,7 +281,7 @@ class VailClient {
|
||||||
number = Number(numberMatch[0])
|
number = Number(numberMatch[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.startsWith("Fortunes")) {
|
if (name.startsWith("Fortunesf")) {
|
||||||
this.roboKeyer.SetPauseMultiplier(number || 1)
|
this.roboKeyer.SetPauseMultiplier(number || 1)
|
||||||
this.repeater = new Repeaters.Fortune(rx, this.roboKeyer)
|
this.repeater = new Repeaters.Fortune(rx, this.roboKeyer)
|
||||||
} else if (name.startsWith("Echo")) {
|
} else if (name.startsWith("Echo")) {
|
||||||
|
@ -378,7 +378,7 @@ class VailClient {
|
||||||
if (stats.connected !== undefined) {
|
if (stats.connected !== undefined) {
|
||||||
this.outputs.SetConnected(stats.connected)
|
this.outputs.SetConnected(stats.connected)
|
||||||
}
|
}
|
||||||
this.updateReading("#note", stats.note || "☁")
|
this.updateReading("#note", stats.note || stats.clients || "😎")
|
||||||
this.updateReading("#lag-value", averageLag)
|
this.updateReading("#lag-value", averageLag)
|
||||||
this.updateReading("#longest-rx-value", longestRxDuration)
|
this.updateReading("#longest-rx-value", longestRxDuration)
|
||||||
this.updateReading("#suggested-delay-value", suggestedDelay)
|
this.updateReading("#suggested-delay-value", suggestedDelay)
|
||||||
|
|
Loading…
Reference in New Issue