diff --git a/web/static/js/viewersCounter.js b/web/static/js/viewersCounter.js new file mode 100644 index 0000000..a8311a3 --- /dev/null +++ b/web/static/js/viewersCounter.js @@ -0,0 +1,18 @@ +function refreshViewersCounter() { + let xhr = new XMLHttpRequest() + xhr.open("GET", "/_stats/", true) + xhr.onload = function () { + console.log(xhr.response) + if (xhr.status === 200) { + let data = JSON.parse(xhr.response) + document.getElementById("connected-people").innerText = data.ConnectedViewers + } + else + console.log("WARNING: status code " + xhr.status + " was returned while fetching connected viewers.") + } + xhr.send() + + setTimeout(refreshViewersCounter, 20000) +} + +refreshViewersCounter() diff --git a/web/template/viewer.html b/web/template/viewer.html index de38b13..b4b8f4f 100644 --- a/web/template/viewer.html +++ b/web/template/viewer.html @@ -17,6 +17,13 @@ rtmps://{{.Cfg.Hostname}}:1935/play/{{.Path}}--> + + + + + + 0 + @@ -36,6 +43,7 @@ +