()
| 59 | } |
| 60 | |
| 61 | connect() { |
| 62 | this.socket = new WebSocket( |
| 63 | location.origin.replace("http", "ws") + |
| 64 | location.pathname.replace(/\/$/, "") + |
| 65 | "/updates", |
| 66 | ); |
| 67 | this.socket.addEventListener("open", () => this.onOpen()); |
| 68 | this.socket.addEventListener("close", (event) => this.onClose(event)); |
| 69 | this.socket.addEventListener("message", (msg) => |
| 70 | this.onMessage(JSON.parse(msg.data)), |
| 71 | ); |
| 72 | this.socket.addEventListener("error", (error) => this.onError(error)); |
| 73 | } |
| 74 | |
| 75 | async onOpen() { |
| 76 | // Send all queued messages. |
no test coverage detected