aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/server-commands/src/socket/socket-io-command.ts
blob: 9c18c2a1fb94eb83cc567e6bccf99a4284df2b62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { io } from 'socket.io-client'
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'

export class SocketIOCommand extends AbstractCommand {

  getUserNotificationSocket (options: OverrideCommandOptions = {}) {
    return io(this.server.url + '/user-notifications', {
      query: { accessToken: options.token ?? this.server.accessToken }
    })
  }

  getLiveNotificationSocket () {
    return io(this.server.url + '/live-videos')
  }

  getRunnersSocket (options: {
    runnerToken: string
  }) {
    return io(this.server.url + '/runners', {
      reconnection: false,
      auth: { runnerToken: options.runnerToken }
    })
  }
}