* Registers a handler to invoke when this protocol object receives a request with the given method. * * Note that this will replace any previous request handler for the same method.
(
requestSchema: T,
handler: (
request: SchemaOutput<T>,
extra: RequestHandlerExtra<SendRequestT, SendNotificationT>
) => SendResultT | Promise<SendResultT>
)
| 1416 | * Note that this will replace any previous request handler for the same method. |
| 1417 | */ |
| 1418 | setRequestHandler<T extends AnyObjectSchema>( |
| 1419 | requestSchema: T, |
| 1420 | handler: ( |
| 1421 | request: SchemaOutput<T>, |
| 1422 | extra: RequestHandlerExtra<SendRequestT, SendNotificationT> |
| 1423 | ) => SendResultT | Promise<SendResultT> |
| 1424 | ): void { |
| 1425 | const method = getMethodLiteral(requestSchema); |
| 1426 | this.assertRequestHandlerCapability(method); |
| 1427 | |
| 1428 | this._requestHandlers.set(method, (request, extra) => { |
| 1429 | const parsed = parseWithCompat(requestSchema, request) as SchemaOutput<T>; |
| 1430 | return Promise.resolve(handler(parsed, extra)); |
| 1431 | }); |
| 1432 | } |
| 1433 | |
| 1434 | /** |
| 1435 | * Removes the request handler for the given method. |
nothing calls this directly
no test coverage detected
searching dependent graphs…