ghostream/web/static/js/viewersCounter.js

13 lines
444 B
JavaScript
Raw Normal View History

// Refresh viewer count by pulling metric from server
function refreshViewersCounter(streamID, period) {
2020-10-05 20:08:39 +00:00
// Distinguish oneDomainPerStream mode
fetch("/_stats/" + streamID)
2020-09-30 13:56:24 +00:00
.then(response => response.json())
.then((data) => document.getElementById("connected-people").innerText = data.ConnectedViewers)
.catch(console.log)
setTimeout(() => {
refreshViewersCounter(streamID, period)
}, period)
}