fix: add more mutex locks for Clients map

This commit is contained in:
Sebastian Mark 2024-11-20 21:51:12 +01:00
parent ab2e8c161d
commit 064a720436
2 changed files with 4 additions and 0 deletions

View file

@ -22,7 +22,9 @@ func handleClientCommands(c models.WebsocketClient) {
_, message, err := ws.ReadMessage()
if err != nil {
// remove client on error/disconnect
mu.Lock()
delete(Clients, ws.LocalAddr())
mu.Unlock()
helper.Logger.Info("Client disconnected:", "msg", err, "host", c.RealIP, "clients", len(Clients))
break
}