JsonRpc.DispatchRequestAsync 方法

定义

在本地 RPC 目标对象上调用该方法,并将响应转换为 JSON-RPC 结果消息。

protected virtual System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage> DispatchRequestAsync (StreamJsonRpc.Protocol.JsonRpcRequest request, StreamJsonRpc.TargetMethod targetMethod, System.Threading.CancellationToken cancellationToken);
abstract member DispatchRequestAsync : StreamJsonRpc.Protocol.JsonRpcRequest * StreamJsonRpc.TargetMethod * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage>
override this.DispatchRequestAsync : StreamJsonRpc.Protocol.JsonRpcRequest * StreamJsonRpc.TargetMethod * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<StreamJsonRpc.Protocol.JsonRpcMessage>
Protected Overridable Function DispatchRequestAsync (request As JsonRpcRequest, targetMethod As TargetMethod, cancellationToken As CancellationToken) As ValueTask(Of JsonRpcMessage)

参数

request
JsonRpcRequest

导致选择接收调度的 targetMethod 传入 JSON-RPC 请求。

targetMethod
TargetMethod

要调用的方法以及要传递给它的自变量。

cancellationToken
CancellationToken

要传递给 StreamJsonRpc.TargetMethod.InvokeAsync(System.Threading.CancellationToken)的取消令牌。

返回

要发回客户端的 JSON-RPC 响应消息。 这绝不应为 null。 如果协议指示客户端不会预期任何响应消息,则会丢弃该消息,而不是传输消息。

注解

此方法的重写应调用核心功能的此基方法。 重写应在任何生成等待之前调用基方法,以保持一致的消息排序,除非替代的目的是专门更改传入消息的顺序。

适用于