Skip to content

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

Consolidate the ping and status request APIs

Gabe Kangas14649fa37361
diff --git a/controllers/ping.go b/controllers/ping.go
deleted file mode 100644
index 81b0ab6e18..0000000000
--- a/controllers/ping.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package controllers
-
-import (
- "net/http"
-
- "github.com/owncast/owncast/core"
- "github.com/owncast/owncast/utils"
-)
-
-func Ping(w http.ResponseWriter, r *http.Request) {
- id := utils.GenerateClientIDFromRequest(r)
- core.SetViewerIdActive(id)
-}
diff --git a/controllers/status.go b/controllers/status.go
index 95c58654f9..0d802e56d3 100644
--- a/controllers/status.go
+++ b/controllers/status.go
@@ -15,27 +15,31 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
status := core.GetStatus()
response := webStatusResponse{
- Online: status.Online,
- ViewerCount: status.ViewerCount,
- LastConnectTime: status.LastConnectTime,
+ Online: status.Online,
+ ViewerCount: status.ViewerCount,
+ LastConnectTime: status.LastConnectTime,
LastDisconnectTime: status.LastDisconnectTime,
- VersionNumber: status.VersionNumber,
- StreamTitle: status.StreamTitle,
+ VersionNumber: status.VersionNumber,
+ StreamTitle: status.StreamTitle,
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(response); err != nil {
InternalErrorHandler(w, err)
}
+
+ // Mark the user who requested this status as an active viewer
+ id := utils.GenerateClientIDFromRequest(r)
+ core.SetViewerIdActive(id)
}
type webStatusResponse struct {
- Online bool `json:"online"`
- ViewerCount int `json:"viewerCount"`
+ Online bool `json:"online"`
+ ViewerCount int `json:"viewerCount"`
LastConnectTime utils.NullTime `json:"lastConnectTime"`
LastDisconnectTime utils.NullTime `json:"lastDisconnectTime"`
VersionNumber string `json:"versionNumber"`
StreamTitle string `json:"streamTitle"`
-}
\ No newline at end of file
+}
diff --git a/router/router.go b/router/router.go
index e130522451..3c0fe6712d 100644
--- a/router/router.go
+++ b/router/router.go
@@ -62,9 +62,6 @@ func Start() error {
// return the list of video variants available
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
- // tell the backend you're an active viewer
- http.HandleFunc("/api/ping", controllers.Ping)
-
// Authenticated admin requests
// Current inbound broadcaster