X-Git-Url: https://code.octet-stream.net/broadcaster/blobdiff_plain/c94fef11f43279165f39680fa0b0922c86702687..8a42be0580469b8fb15fc3369724332f063dca4a:/server/web_sync.go diff --git a/server/web_sync.go b/server/web_sync.go index e59403d..a6b1a6e 100644 --- a/server/web_sync.go +++ b/server/web_sync.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "code.octet-stream.net/broadcaster/protocol" + "code.octet-stream.net/broadcaster/internal/protocol" "golang.org/x/net/websocket" ) @@ -18,12 +18,12 @@ func WebSync(ws *websocket.Conn) { badRead := false isAuthenticated := false - var user string + var user User for { // Ignore any massively oversize messages n, err := ws.Read(buf) if err != nil { - if user != "" { + if user.Username != "" { log.Println("Lost websocket to user:", user) } else { log.Println("Lost unauthenticated website websocket") @@ -40,9 +40,9 @@ func WebSync(ws *websocket.Conn) { if !isAuthenticated { token := string(buf[:n]) - u, err := db.GetUserForSession(token) + u, err := users.GetUserForSession(token) if err != nil { - log.Println("Could not find user for offered token", token) + log.Println("Could not find user for offered token", token, err) ws.Close() return } @@ -145,7 +145,7 @@ func sendRadioStatusToWeb(ws *websocket.Conn) error { Radios: webStatuses, } buf := new(strings.Builder) - tmpl := template.Must(template.ParseFiles("templates/radios.partial.html")) + tmpl := template.Must(template.ParseFS(content, "templates/radios.partial.html")) tmpl.Execute(buf, data) _, err := ws.Write([]byte(buf.String())) return err