Sum all user counts for each substream to have the total number of clients that are connected to a stream

This commit is contained in:
Yohann D'ANELLO 2020-10-18 20:44:31 +02:00
parent 37b5106c4e
commit b5aac93c97
1 changed files with 9 additions and 6 deletions

View File

@ -150,14 +150,17 @@ func staticHandler() http.Handler {
}
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
name := strings.Replace(r.URL.Path[7:], "/", "", -1)
name := strings.SplitN(strings.Replace(r.URL.Path[7:], "/", "", -1), "@", 2)[0]
userCount := 0
// Get requested stream
stream, ok := streams[name]
if ok {
// Get number of output channels
userCount = stream.ClientCount()
// Get all substreams
for _, outputType := range []string{"", "@720p", "@480p", "@360p", "@240p", "@text"} {
// Get requested stream
stream, ok := streams[name+outputType]
if ok {
// Get number of output channels
userCount += stream.ClientCount()
}
}
// Display connected users statistics