Class JsonRpcPipeChannel
- Namespace
- Nerdbank.JsonRpc
- Assembly
- Nerdbank.JsonRpc.dll
Provides an abstract channel for transporting JSON-RPC messages over a duplex pipe, enabling asynchronous message exchange between endpoints.
public abstract class JsonRpcPipeChannel : Channel<JsonRpcMessage>, IAsyncDisposable
- Inheritance
-
JsonRpcPipeChannel
- Implements
- Derived
- Inherited Members
Remarks
Derived classes select the encoding and implement serialization, deserialization, and any framing. This base class manages the pipe and message queues without choosing a wire format.
Constructors
JsonRpcPipeChannel(IDuplexPipe, Channel<JsonRpcMessage>, Channel<JsonRpcMessage>)
Initializes a new instance of the JsonRpcPipeChannel class with deferred transport startup.
protected JsonRpcPipeChannel(IDuplexPipe pipe, Channel<JsonRpcMessage> inboundChannel, Channel<JsonRpcMessage> outboundChannel)
Parameters
pipeIDuplexPipeThe connected duplex pipe.
inboundChannelChannel<JsonRpcMessage>The queue for received messages.
outboundChannelChannel<JsonRpcMessage>The queue for messages to send.
Properties
Encoding
Gets the encoding used by this transport.
public abstract JsonRpcEncoding Encoding { get; }
Property Value
Logger
protected ILogger Logger { get; }
Property Value
MaximumMessageSize
Gets the configured maximum size, in bytes, of a message.
protected int MaximumMessageSize { get; }
Property Value
Serializer
Gets the serializer selected by this channel for application values.
public abstract JsonRpcSerializer Serializer { get; }
Property Value
Methods
CreateInboundChannel(int?)
protected static Channel<JsonRpcMessage> CreateInboundChannel(int? capacity)
Parameters
capacityint?
Returns
CreateOutboundChannel(int?)
protected static Channel<JsonRpcMessage> CreateOutboundChannel(int? capacity)
Parameters
capacityint?
Returns
DisposeAsync()
Stops transport processing and completes both sides of the pipe.
public ValueTask DisposeAsync()
Returns
- ValueTask
The bounded transport cleanup operation.
Exceptions
- OperationCanceledException
A transport processor did not stop within the one-second cleanup budget.
ReceiveMessagesAsync(PipeReader, CancellationToken)
protected abstract IAsyncEnumerable<JsonRpcMessage> ReceiveMessagesAsync(PipeReader reader, CancellationToken cancellationToken)
Parameters
readerPipeReadercancellationTokenCancellationToken
Returns
SendMessageAsync(PipeWriter, JsonRpcMessage, CancellationToken)
protected abstract ValueTask SendMessageAsync(PipeWriter writer, JsonRpcMessage message, CancellationToken cancellationToken)
Parameters
writerPipeWritermessageJsonRpcMessagecancellationTokenCancellationToken
Returns
Start()
Starts transport processing after the channel and its owning JsonRpc instance have been configured.
public void Start()