mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 04:26:38 +08:00
fix: refresh emby sessions in realtime
This commit is contained in:
@@ -16,8 +16,9 @@ func embyNoContentHandler(_ *service.Container) gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func embyWebSocketHandler(_ *service.Container) gin.HandlerFunc {
|
||||
func embyWebSocketHandler(svc *service.Container, jwtSecret string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
recordEmbyPublicSessionActivity(c, svc, jwtSecret)
|
||||
if !websocket.IsWebSocketUpgrade(c.Request) {
|
||||
c.Status(http.StatusNoContent)
|
||||
return
|
||||
@@ -45,6 +46,7 @@ func embyWebSocketHandler(_ *service.Container) gin.HandlerFunc {
|
||||
case <-done:
|
||||
return
|
||||
case <-ticker.C:
|
||||
recordEmbyPublicSessionActivity(c, svc, jwtSecret)
|
||||
_ = conn.SetWriteDeadline(time.Now().Add(10 * time.Second))
|
||||
if err := conn.WriteMessage(websocket.PingMessage, nil); err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user