mirror of
				https://github.com/skidoodle/spotify-ws
				synced 2025-10-09 05:22:43 +02:00 
			
		
		
		
	fix unhandled stuff
This commit is contained in:
		
							
								
								
									
										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)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user