]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/peertube-socket.ts
Live views update
[github/Chocobozzz/PeerTube.git] / server / lib / peertube-socket.ts
index 5fc5bc20b70c2d77e494ccc5eca2d77d45ec3407..e27963e606b52d6ea6c4ade1272000aec5f50441 100644 (file)
@@ -69,7 +69,18 @@ class PeerTubeSocket {
     const data: LiveVideoEventPayload = { state: video.state }
     const type: LiveVideoEventType = 'state-change'
 
-    logger.debug('Sending video live new state notification of %s.', video.url)
+    logger.debug('Sending video live new state notification of %s.', video.url, { state: video.state })
+
+    this.liveVideosNamespace
+      .in(video.id)
+      .emit(type, data)
+  }
+
+  sendVideoViewsUpdate (video: MVideo) {
+    const data: LiveVideoEventPayload = { views: video.views }
+    const type: LiveVideoEventType = 'views-change'
+
+    logger.debug('Sending video live views update notification of %s.', video.url, { views: video.views })
 
     this.liveVideosNamespace
       .in(video.id)