Unsubscribe from a session's events.
(sessionId: string)
| 168 | |
| 169 | /** Unsubscribe from a session's events. */ |
| 170 | unsubscribe(sessionId: string): void { |
| 171 | this.subscriptions.delete(sessionId); |
| 172 | // Also cancel a subscribe that was queued before server_hello; otherwise |
| 173 | // onServerHello would merge it back into the active subscription set. |
| 174 | const pendingIdx = this.pendingSubscriptions.findIndex((p) => p.sessionId === sessionId); |
| 175 | if (pendingIdx !== -1) this.pendingSubscriptions.splice(pendingIdx, 1); |
| 176 | if (this.connected && this.ws) { |
| 177 | this.send({ |
| 178 | type: 'unsubscribe', |
| 179 | id: this.nextId(), |
| 180 | payload: { session_ids: [sessionId] }, |
| 181 | }); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Send a WS abort control message for a prompt. |