merge ping and stale check

This commit is contained in:
Sebastian Mark 2024-11-21 08:47:58 +01:00
parent c76ea3628b
commit 58ac2d2950

View file

@ -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())
}