 | JsonRpcClientHandlerSendAsync Method |
[This is preliminary documentation and is subject to change.]
Asynchronously sends a JSON RPC Request message, and wait for the Response (if the Request is not a Notification).
Namespace:
JsonRpc.Client
Assembly:
JsonRpc.Commons (in JsonRpc.Commons.dll) Version: 0.5.4+1bad715934a0ae5922832940ca44bbbdaa509cfe
Syntaxpublic abstract Task<ResponseMessage> SendAsync(
RequestMessage request,
CancellationToken cancellationToken
)
Public MustOverride Function SendAsync (
request As RequestMessage,
cancellationToken As CancellationToken
) As Task(Of ResponseMessage)
Dim instance As JsonRpcClientHandler
Dim request As RequestMessage
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of ResponseMessage)
returnValue = instance.SendAsync(request,
cancellationToken)
public:
virtual Task<ResponseMessage^>^ SendAsync(
RequestMessage^ request,
CancellationToken cancellationToken
) abstract
abstract SendAsync :
request : RequestMessage *
cancellationToken : CancellationToken -> Task<ResponseMessage>
Parameters
- request
- Type: JsonRpc.MessagesRequestMessage
The request message to be sent. - cancellationToken
- Type: System.ThreadingCancellationToken
A token used to cancel the transmitting request, or to stop waiting for the Response.
Return Value
Type:
TaskResponseMessageA task that returns JSON RPC response, or
null if the Request is a Notification.
Implements
IJsonRpcClientHandlerSendAsync(RequestMessage, CancellationToken)
ExceptionsException | Condition |
---|
ArgumentNullException | request is null. |
JsonRpcClientException | An exception has occurred while transmitting the request.
Note that a JSON RPC Response with Error will be returned and no exception should be thrown. |
Remarks
If a JSON RPC Request has already been sent, cancellation via
cancellationToken will only make the returned task stop waiting for the response.
To actually notifies the RPC server to cancel certain request, both the client and server side should
make a contract on how to cancel an ongoing request, for example, by sending a special "cancellation"
notification.
See Also