-import { Socket } from 'dgram'
import { Server } from 'http'
import * as SocketIO from 'socket.io'
import { MVideo } from '@server/types/models'
private constructor () {}
init (server: Server) {
- const io = SocketIO(server)
+ const io = new SocketIO.Server(server)
io.of('/user-notifications')
.use(authenticateSocket)
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)