Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Remove stale client purging. Use sockets to count clients. #323

Gabe Kangas53ae300dfa2f
diff --git a/controllers/index.go b/controllers/index.go
index f83a6b059d..7f11ea4d99 100644
--- a/controllers/index.go
+++ b/controllers/index.go
@@ -13,7 +13,6 @@ import (
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core"
- "github.com/owncast/owncast/models"
"github.com/owncast/owncast/router/middleware"
"github.com/owncast/owncast/utils"
)
@@ -47,9 +46,6 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
if path.Ext(r.URL.Path) == ".m3u8" {
middleware.DisableCache(w)
-
- client := models.GenerateClientFromRequest(r)
- core.SetClientActive(client)
}
// Set a cache control max-age header
diff --git a/core/chat/client.go b/core/chat/client.go
index cd7018cdf7..361d788e7a 100644
--- a/core/chat/client.go
+++ b/core/chat/client.go
@@ -57,8 +57,8 @@ func NewClient(ws *websocket.Conn) *Client {
ipAddress := utils.GetIPAddressFromRequest(ws.Request())
userAgent := ws.Request().UserAgent()
- clientID := utils.GenerateClientIDFromRequest(ws.Request())
socketID, _ := shortid.Generate()
+ clientID := socketID
return &Client{time.Now(), 0, userAgent, ipAddress, nil, clientID, nil, socketID, ws, ch, pingch, usernameChangeChannel, doneCh}
}
diff --git a/core/chat/server.go b/core/chat/server.go
index 15c6a37c2f..096c743bdf 100644
--- a/core/chat/server.go
+++ b/core/chat/server.go
@@ -108,7 +108,7 @@ func (s *server) Listen() {
// remove a client
case c := <-s.delCh:
delete(s.Clients, c.socketID)
- s.listener.ClientRemoved(c.ClientID)
+ s.listener.ClientRemoved(c.socketID)
// message was recieved from a client and should be sanitized, validated
// and distributed to other clients.
diff --git a/core/stats.go b/core/stats.go
index 30d7e6fadf..2d180db628 100644
--- a/core/stats.go
+++ b/core/stats.go
@@ -43,32 +43,9 @@ func setupStats() error {
}
}()
- staleViewerPurgeTimer := time.NewTicker(3 * time.Second)
- go func() {
- for {
- select {
- case <-staleViewerPurgeTimer.C:
- purgeStaleViewers()
- }
- }
- }()
-
return nil
}
-func purgeStaleViewers() {
- for clientID, client := range _stats.Clients {
- if client.LastSeen.IsZero() {
- continue
- }
-
- timeSinceLastActive := time.Since(client.LastSeen).Minutes()
- if timeSinceLastActive > 1 {
- RemoveClient(clientID)
- }
- }
-}
-
//IsStreamConnected checks if the stream is connected or not
func IsStreamConnected() bool {
if !_stats.StreamConnected {