mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-27 11:28:51 +02:00
Make viewers counter period configurable
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
function refreshViewersCounter() {
|
||||
// Refresh viewer count by pulling metric from server
|
||||
function refreshViewersCounter(period) {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("GET", "/_stats/", true)
|
||||
xhr.onload = function () {
|
||||
@ -12,7 +13,7 @@ function refreshViewersCounter() {
|
||||
}
|
||||
xhr.send()
|
||||
|
||||
setTimeout(refreshViewersCounter, 20000)
|
||||
setTimeout(() => {
|
||||
refreshViewersCounter(period)
|
||||
}, period)
|
||||
}
|
||||
|
||||
refreshViewersCounter()
|
||||
|
@ -50,5 +50,10 @@
|
||||
{{end}}
|
||||
]
|
||||
startPeerConnection()
|
||||
|
||||
// Wait a bit before pulling viewers counter for the first time
|
||||
setTimeout(() => {
|
||||
refreshViewersCounter({{.Cfg.ViewersCounterRefreshPeriod}})
|
||||
}, 1000)
|
||||
</script>
|
||||
{{end}}
|
11
web/web.go
11
web/web.go
@ -15,11 +15,12 @@ import (
|
||||
|
||||
// Options holds web package configuration
|
||||
type Options struct {
|
||||
ListenAddress string
|
||||
Name string
|
||||
Hostname string
|
||||
Favicon string
|
||||
WidgetURL string
|
||||
ListenAddress string
|
||||
Name string
|
||||
Hostname string
|
||||
Favicon string
|
||||
WidgetURL string
|
||||
ViewersCounterRefreshPeriod int
|
||||
|
||||
// Copied from WebRTC configuration
|
||||
STUNServers []string
|
||||
|
Reference in New Issue
Block a user