MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / getActiveClientCount

Function getActiveClientCount

src/buffer.go:33–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31}
32
33func 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
67func getActivePlaylistCount() (count int) {
68 count = 0

Callers 1

setDefaultResponseDataFunction · 0.85

Calls 1

cleanUpStaleClientsFunction · 0.85

Tested by

no test coverage detected