Class RDCorePlatformChannelExtensions
Sends and answers typed rdcore/* messages over an IRDCorePlatformChannel, written and read with Options.
public static class RDCorePlatformChannelExtensions
- Inheritance
-
RDCorePlatformChannelExtensions
- Inherited Members
Methods
OnNotification<TParams>(IRDCorePlatformChannel, string, Func<TParams, CancellationToken, Task>)
Handles the notifications of a method the server sends the client.
public static IDisposable OnNotification<TParams>(this IRDCorePlatformChannel channel, string method, Func<TParams, CancellationToken, Task> handler)
Parameters
channelIRDCorePlatformChannelThe connection to the server.
methodstringThe JSON-RPC method.
handlerFunc<TParams, CancellationToken, Task>Handles a notification.
Returns
- IDisposable
The registration; disposing it stops handling the method.
Type Parameters
TParamsThe type of the notification's parameters.
Remarks
A notification sent with no params is read as {}; one whose params are not a TParams fails with
RDCorePlatformInvalidParamsException.
Exceptions
- InvalidOperationException
The method is already handled on the channel.
OnRequest<TParams, TResult>(IRDCorePlatformChannel, string, Func<TParams, CancellationToken, Task<TResult>>)
Answers the requests of a method the server sends the client.
public static IDisposable OnRequest<TParams, TResult>(this IRDCorePlatformChannel channel, string method, Func<TParams, CancellationToken, Task<TResult>> handler)
Parameters
channelIRDCorePlatformChannelThe connection to the server.
methodstringThe JSON-RPC method.
handlerFunc<TParams, CancellationToken, Task<TResult>>Answers a request.
Returns
- IDisposable
The registration; disposing it stops answering the method.
Type Parameters
TParamsThe type of the request's parameters.
TResultThe type of its result.
Remarks
A request sent with no params is read as {}: the parameters with every member at its default. A request whose params are not a
TParams is not given to the handler: it fails with RDCorePlatformInvalidParamsException.
Exceptions
- InvalidOperationException
The method is already answered on the channel.
SendNotificationAsync<TParams>(IRDCorePlatformChannel, string, TParams, CancellationToken)
Sends a notification.
public static Task SendNotificationAsync<TParams>(this IRDCorePlatformChannel channel, string method, TParams parameters, CancellationToken token)
Parameters
channelIRDCorePlatformChannelThe connection to the server.
methodstringThe JSON-RPC method.
parametersTParamsThe parameters.
tokenCancellationTokenCancels before the notification is sent.
Returns
- Task
A task that completes once the notification is sent.
Type Parameters
TParamsThe type of the notification's parameters.
SendRequestAsync<TParams, TResult>(IRDCorePlatformChannel, string, TParams, CancellationToken)
Sends a request and reads its result.
public static Task<TResult> SendRequestAsync<TParams, TResult>(this IRDCorePlatformChannel channel, string method, TParams parameters, CancellationToken token)
Parameters
channelIRDCorePlatformChannelThe connection to the server.
methodstringThe JSON-RPC method.
parametersTParamsThe parameters.
tokenCancellationTokenCancels the request.
Returns
- Task<TResult>
The result the server answered.
Type Parameters
TParamsThe type of the request's parameters.
TResultThe type of its result.
Exceptions
- JsonException
The server answered
null, or a result that is not aTResult.