mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-29 07:30:54 +02:00
Count also the viewers that are streaming directly from their video player in the connected users stats
This commit is contained in:
@ -3,6 +3,7 @@ package web
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"gitlab.crans.org/nounous/ghostream/stream/srt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net"
|
||||
@ -133,11 +134,12 @@ func staticHandler() http.Handler {
|
||||
}
|
||||
|
||||
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Display connected users stats
|
||||
// Display connected users stats, from WebRTC or streaming directly from a video player
|
||||
streamID := strings.Replace(r.URL.Path[7:], "/", "", -1)
|
||||
enc := json.NewEncoder(w)
|
||||
err := enc.Encode(struct {
|
||||
ConnectedViewers int
|
||||
}{webrtc.GetNumberConnectedSessions(strings.Replace(r.URL.Path[7:], "/", "", -1))})
|
||||
}{webrtc.GetNumberConnectedSessions(streamID) + srt.GetNumberConnectedSessions(streamID)})
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to generate JSON.", http.StatusInternalServerError)
|
||||
log.Printf("Failed to generate JSON: %s", err)
|
||||
|
Reference in New Issue
Block a user