From 519be9d3b418b646c4c1435703ea1218796d329d Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 24 Sep 2020 20:27:47 -0700 Subject: [PATCH] Don't update viewer counts if a live stream session is not active. --- core/stats.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/stats.go b/core/stats.go index 5a2b2a0cb..388d2f049 100644 --- a/core/stats.go +++ b/core/stats.go @@ -88,8 +88,12 @@ func SetClientActive(clientID string) { l.Lock() _stats.Clients[clientID] = time.Now() l.Unlock() - _stats.SessionMaxViewerCount = int(math.Max(float64(len(_stats.Clients)), float64(_stats.SessionMaxViewerCount))) - _stats.OverallMaxViewerCount = int(math.Max(float64(_stats.SessionMaxViewerCount), float64(_stats.OverallMaxViewerCount))) + + // Don't update viewer counts if a live stream session is not active. + if _stats.StreamConnected { + _stats.SessionMaxViewerCount = int(math.Max(float64(len(_stats.Clients)), float64(_stats.SessionMaxViewerCount))) + _stats.OverallMaxViewerCount = int(math.Max(float64(_stats.SessionMaxViewerCount), float64(_stats.OverallMaxViewerCount))) + } } //RemoveClient removes a client from the active clients record