()
| 57 | } |
| 58 | |
| 59 | private async connect() { |
| 60 | const dtdUri = await this.dtdProcess.dtdUri; |
| 61 | if (!dtdUri) |
| 62 | return; |
| 63 | const dtdSecret = await this.dtdProcess.dtdSecret; |
| 64 | |
| 65 | this.logger.info(`Connecting to DTD at ${dtdUri}...`); |
| 66 | const socket = new ws.WebSocket(dtdUri, { followRedirects: true }); |
| 67 | attachPing(socket); |
| 68 | socket.on("open", () => this.handleOpen()); |
| 69 | // eslint-disable-next-line @typescript-eslint/no-base-to-string |
| 70 | socket.on("message", (data) => this.handleData(data.toString())); |
| 71 | socket.on("close", () => this.handleWebSocketClose()); |
| 72 | socket.on("error", (e) => this.handleError(e)); |
| 73 | |
| 74 | this.connection = { socket, dtdUri, dtdSecret }; |
| 75 | } |
| 76 | |
| 77 | protected async handleOpen(): Promise<void> { |
| 78 | this.logger.info(`Connected to DTD`); |
no test coverage detected