直播:status 返回观看人数,后台开播页轮询展示

Made-with: Cursor
This commit is contained in:
whm
2026-03-26 15:30:15 +08:00
parent 0aa11575a6
commit 4112ea4447
2 changed files with 47 additions and 1 deletions

View File

@@ -45,8 +45,9 @@ func handleLiveStatus(c *gin.Context) {
}
h.mu.RLock()
live := h.publishConn != nil && h.pubPC != nil && len(h.forwarders) > 0
viewers := len(h.viewers)
h.mu.RUnlock()
c.JSON(http.StatusOK, gin.H{"live": live})
c.JSON(http.StatusOK, gin.H{"live": live, "viewers": viewers})
}
func handleLiveWS(c *gin.Context) {