()
| 59 | } |
| 60 | |
| 61 | disconnect(): void { |
| 62 | const error = new Error("Read-only relay observer disconnected."); |
| 63 | this.generation++; |
| 64 | |
| 65 | if (this.wsId !== null) { |
| 66 | void closeWebSocket(this.wsId, "observer disconnected"); |
| 67 | this.wsId = null; |
| 68 | } |
| 69 | |
| 70 | if (this.authRequest) { |
| 71 | window.clearTimeout(this.authRequest.timeout); |
| 72 | this.authRequest.reject(error); |
| 73 | this.authRequest = null; |
| 74 | } |
| 75 | |
| 76 | for (const [subId, pending] of this.histories) { |
| 77 | window.clearTimeout(pending.timeout); |
| 78 | pending.reject(error); |
| 79 | this.histories.delete(subId); |
| 80 | } |
| 81 | |
| 82 | this.onMessageChannel = null; |
| 83 | this.connectPromise = null; |
| 84 | } |
| 85 | |
| 86 | async fetchEvents(filter: RelaySubscriptionFilter): Promise<RelayEvent[]> { |
| 87 | await this.connect(); |
no test coverage detected