* Install a handler invoked on every `event.approval.requested` frame. * The handler's return value is POSTed to `/sessions/{sid}/approvals/{aid}`. * Returns an unsubscribe handle (also auto-disposed by `close()`).
(
handler: (req: ApprovalRequest) => Promise<ApprovalResponse> | ApprovalResponse,
)
| 555 | * Returns an unsubscribe handle (also auto-disposed by `close()`). |
| 556 | */ |
| 557 | onApprovalRequested( |
| 558 | handler: (req: ApprovalRequest) => Promise<ApprovalResponse> | ApprovalResponse, |
| 559 | ): () => void { |
| 560 | const ws = this._requireWs(); |
| 561 | const unsubscribe = installReverseRpcHandler<ApprovalRequest, ApprovalResponse>(ws, { |
| 562 | requestEventType: 'event.approval.requested', |
| 563 | idField: 'approval_id', |
| 564 | buildPath: (sid, aid) => `/sessions/${sid}/approvals/${aid}`, |
| 565 | handler, |
| 566 | postResolve: (sid, aid, body) => this.http.resolveApproval(sid, aid, body), |
| 567 | logger: this._logger, |
| 568 | }); |
| 569 | this._disposers.push(unsubscribe); |
| 570 | return () => { |
| 571 | const idx = this._disposers.indexOf(unsubscribe); |
| 572 | if (idx >= 0) this._disposers.splice(idx, 1); |
| 573 | unsubscribe(); |
| 574 | }; |
| 575 | } |
| 576 | |
| 577 | /** |
| 578 | * Install a handler invoked on every `event.question.requested` frame. |
no test coverage detected