mirror of
https://github.com/skidoodle/spotify-ws.git
synced 2025-02-15 06:09:14 +01:00
fix unhandled stuff
This commit is contained in:
parent
a209be089b
commit
cdec626875
1 changed files with 12 additions and 3 deletions
15
main.go
15
main.go
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue