GoTomato/internal/websocket/staleClients.go

22 lines
313 B
Go
Raw Normal View History

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