(uri: string)
| 351 | private eventListeners: { [key: string]: (message: VMEvent) => void } = {}; |
| 352 | |
| 353 | constructor(uri: string) { |
| 354 | const url = new URL(uri); |
| 355 | if (url.protocol.startsWith("http")) { |
| 356 | url.protocol = url.protocol === "https" ? "wss" : "ws"; |
| 357 | uri = url.toString(); |
| 358 | } |
| 359 | this.socket = new WebSocket(uri, { followRedirects: true }); |
| 360 | this.socket.on("message", (data: Buffer) => this.handleData(data.toString())); |
| 361 | } |
| 362 | |
| 363 | public onOpen(cb: () => void) { |
| 364 | this.socket.on("open", cb); |
nothing calls this directly
no test coverage detected