| 62 | ); |
| 63 | |
| 64 | constructor( |
| 65 | private readonly socketUrl: string, |
| 66 | private readonly io: typeof _io |
| 67 | ) { |
| 68 | console.log(`Socket with url ${socketUrl} created!`); |
| 69 | |
| 70 | const ioCallable = <any>this.io; |
| 71 | |
| 72 | this.ioSocket = ioCallable(`${this.socketUrl}`, { |
| 73 | reconnection: false, |
| 74 | }); |
| 75 | |
| 76 | this.connectionStatus |
| 77 | .pipe( |
| 78 | filter( |
| 79 | (status) => |
| 80 | status === ConnectionStatus.Disconnected || |
| 81 | status === ConnectionStatus.ConnectError |
| 82 | ), |
| 83 | delay(1000) |
| 84 | ) |
| 85 | .subscribe(() => { |
| 86 | this.connect(); |
| 87 | }); |
| 88 | } |
| 89 | |
| 90 | on(eventName: string, callback: () => void) { |
| 91 | this.ioSocket.on(eventName, callback); |