From 8fcbb05183dabc6fff8d614a5a3128509be461e9 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 26 Apr 2020 13:08:43 -0600 Subject: [PATCH] Pull some JS functionality into classes --- main.go | 17 ++- static/index.html | 15 ++- static/vail.js | 332 +++++++++++++++++++++++++++++++++------------- 3 files changed, 267 insertions(+), 97 deletions(-) diff --git a/main.go b/main.go index 28b6118..4c9dc1d 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "log" "net/http" "golang.org/x/net/websocket" + "time" ) var book Book @@ -17,13 +18,23 @@ func (c Client) Handle(ws *websocket.Conn) { book.Join(c.repeaterName, ws) defer book.Part(c.repeaterName, ws) + offset := int64{0} for { + var m Message buf := make([]byte, ws.MaxPayloadBytes) - n, err := ws.Read(buf) - if err != nil { + + if n, err := ws.Read(buf); err != nil { break + } else { + buf = buf[:n] } - buf = buf[:n] + + if err := m.UnmarshalBinary(buf); err != nil { + log("Unmarshal error:", err) + continue + } + + book.Send(c.repeaterName, buf) } } diff --git a/static/index.html b/static/index.html index 5d59a53..5b8827b 100644 --- a/static/index.html +++ b/static/index.html @@ -68,12 +68,12 @@ @@ -87,6 +87,17 @@
- -
+

+ dit length + + +