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() delete(Clients, client.Conn.LocalAddr()) } } mu.Unlock() } }