GoTomato/internal/websocket/staleClients.go

21 lines
313 B
Go

package websocket
import (
"time"
)
// Check and remove stale clients
func RemoveStaleClients() {
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for range ticker.C {
mu.Lock()
for _, client := range Clients {
if client.IsStale() {
client.Conn.Close()
}
}
mu.Unlock()
}
}