Send `subscribe` and await its ack. Tracks the session for `close()`.
(sid: string)
| 409 | |
| 410 | /** Send `subscribe` and await its ack. Tracks the session for `close()`. */ |
| 411 | async subscribe(sid: string): Promise<void> { |
| 412 | const ws = this._requireWs(); |
| 413 | if (this._subscribed.has(sid)) return; |
| 414 | const id = `sub-${ulid()}`; |
| 415 | const ack = await ws.sendAndAwaitAck( |
| 416 | { type: 'subscribe', id, payload: { session_ids: [sid] } }, |
| 417 | this._controlAckTimeoutMs, |
| 418 | ); |
| 419 | if (ack.code !== 0) { |
| 420 | throw new Error(`subscribe rejected (code=${ack.code}): ${ack.msg ?? 'no message'}`); |
| 421 | } |
| 422 | this._subscribed.add(sid); |
| 423 | } |
| 424 | |
| 425 | /** Send `unsubscribe` and await its ack. */ |
| 426 | async unsubscribe(sid: string): Promise<void> { |
no test coverage detected