Table of Contents

Class RDCorePlatformChannelExtensions

Namespace
RDCore.SDK.Client
Assembly
RDCore.SDK.Protocol.dll

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

channel IRDCorePlatformChannel

The connection to the server.

method string

The JSON-RPC method.

handler Func<TParams, CancellationToken, Task>

Handles a notification.

Returns

IDisposable

The registration; disposing it stops handling the method.

Type Parameters

TParams

The 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

channel IRDCorePlatformChannel

The connection to the server.

method string

The JSON-RPC method.

handler Func<TParams, CancellationToken, Task<TResult>>

Answers a request.

Returns

IDisposable

The registration; disposing it stops answering the method.

Type Parameters

TParams

The type of the request's parameters.

TResult

The 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

channel IRDCorePlatformChannel

The connection to the server.

method string

The JSON-RPC method.

parameters TParams

The parameters.

token CancellationToken

Cancels before the notification is sent.

Returns

Task

A task that completes once the notification is sent.

Type Parameters

TParams

The 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

channel IRDCorePlatformChannel

The connection to the server.

method string

The JSON-RPC method.

parameters TParams

The parameters.

token CancellationToken

Cancels the request.

Returns

Task<TResult>

The result the server answered.

Type Parameters

TParams

The type of the request's parameters.

TResult

The type of its result.

Exceptions

JsonException

The server answered null, or a result that is not a TResult.