()
| 31 | } |
| 32 | |
| 33 | func getActiveClientCount() (count int) { |
| 34 | count = 0 |
| 35 | cleanUpStaleClients() // Ensure stale clients are removed first |
| 36 | |
| 37 | BufferInformation.Range(func(key, value interface{}) bool { |
| 38 | playlist, ok := value.(Playlist) |
| 39 | if !ok { |
| 40 | fmt.Printf("Invalid type assertion for playlist: %v\n", value) |
| 41 | return true |
| 42 | } |
| 43 | |
| 44 | for clientID, client := range playlist.Clients { |
| 45 | if client.Connection < 0 { |
| 46 | fmt.Printf("Client ID %d has negative connections: %d. Resetting to 0.\n", clientID, client.Connection) |
| 47 | client.Connection = 0 |
| 48 | playlist.Clients[clientID] = client |
| 49 | BufferInformation.Store(key, playlist) |
| 50 | } |
| 51 | if client.Connection > 1 { |
| 52 | fmt.Printf("Client ID %d has suspiciously high connections: %d. Resetting to 1.\n", clientID, client.Connection) |
| 53 | client.Connection = 1 |
| 54 | playlist.Clients[clientID] = client |
| 55 | BufferInformation.Store(key, playlist) |
| 56 | } |
| 57 | count += client.Connection |
| 58 | } |
| 59 | |
| 60 | fmt.Printf("Playlist %s has %d active clients\n", playlist.PlaylistID, len(playlist.Clients)) |
| 61 | return true |
| 62 | }) |
| 63 | |
| 64 | return count |
| 65 | } |
| 66 | |
| 67 | func getActivePlaylistCount() (count int) { |
| 68 | count = 0 |
no test coverage detected