From 2d5fa692d3cf36e3510a6084dc36dc4ae44481be Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 21 Nov 2024 08:47:58 +0100 Subject: [PATCH] merge ping and stale check --- internal/websocket/staleClients.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/websocket/staleClients.go b/internal/websocket/staleClients.go index 6ba2128..d64960e 100644 --- a/internal/websocket/staleClients.go +++ b/internal/websocket/staleClients.go @@ -30,13 +30,7 @@ func RemoveStaleClients() { for range ticker.C { mu.Lock() for _, client := range Clients { - if !sendPing(client) { - client.Conn.Close() - delete(Clients, client.Conn.LocalAddr()) - - } - - if isStale(client) { + if !sendPing(client) || isStale(client) { client.Conn.Close() delete(Clients, client.Conn.LocalAddr()) }