- socket.on('subscribe', ({ videoId }) => socket.join(videoId))
- socket.on('unsubscribe', ({ videoId }) => socket.leave(videoId))
+ socket.on('subscribe', ({ videoId }) => {
+ if (!isIdValid(videoId)) return
+
+ /* eslint-disable @typescript-eslint/no-floating-promises */
+ socket.join(videoId)
+ })
+
+ socket.on('unsubscribe', ({ videoId }) => {
+ if (!isIdValid(videoId)) return
+
+ /* eslint-disable @typescript-eslint/no-floating-promises */
+ socket.leave(videoId)
+ })
+ })
+
+ io.of('/runners')
+ .use(authenticateRunnerSocket)
+ .on('connection', socket => {
+ const runner: MRunner = socket.handshake.auth.runner
+
+ logger.debug(`New runner "${runner.name}" connected to the notification system.`)
+
+ this.runnerSockets.add(socket)
+
+ socket.on('disconnect', () => {
+ logger.debug(`Runner "${runner.name}" disconnected from the notification system.`)
+
+ this.runnerSockets.delete(socket)
+ })