fix unhandled stuff

This commit is contained in:
skidoodle 2024-11-25 10:38:23 +01:00
parent a209be089b
commit cdec626875

15
main.go
View file

@ -85,7 +85,10 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
disconnect <- ws disconnect <- ws
ws.Close() err := ws.Close()
if err != nil {
return
}
}() }()
// Immediately send the current track to the newly connected client // Immediately send the current track to the newly connected client
@ -124,7 +127,10 @@ func ConnectionManager() {
clientsMutex.Lock() clientsMutex.Lock()
if _, ok := clients[client]; ok { if _, ok := clients[client]; ok {
delete(clients, client) delete(clients, client)
client.Close() err := client.Close()
if err != nil {
return
}
} }
clientsMutex.Unlock() clientsMutex.Unlock()
} }
@ -138,7 +144,10 @@ func MessageHandler() {
for client := range clients { for client := range clients {
err := client.WriteJSON(msg) err := client.WriteJSON(msg)
if err != nil { if err != nil {
client.Close() err := client.Close()
if err != nil {
return
}
delete(clients, client) delete(clients, client)
} }
} }