Class MessageFormatterDuplexPipeTracker
- Namespace
- StreamJsonRpc.Reflection
- Assembly
- StreamJsonRpc.dll
Assists IJsonRpcMessageFormatter implementations with supporting marshaling IDuplexPipe over JSON-RPC.
public class MessageFormatterDuplexPipeTracker : IDisposableObservable, IDisposable
- Inheritance
-
MessageFormatterDuplexPipeTracker
- Implements
- Inherited Members
Remarks
Lifetime rules:
- The IDuplexPipe always originates on the client and passed as an argument to the server. Servers are not allowed to return IDuplexPipe to clients because the server would have no feedback if the client dropped it, leaking resources.
- The client can only send an IDuplexPipe in a request (that expects a response). Notifications would not provide the client with feedback that the server dropped it, leaking resources.
- The client will immediately terminate the IDuplexPipe if the server returns ANY error in response to the request, since the server may not be aware of the IDuplexPipe.
- The IDuplexPipe will NOT be terminated when a successful response is received from the server. Client and server are expected to negotiate the end of the IDuplexPipe themselves.
Constructors
MessageFormatterDuplexPipeTracker(JsonRpc, IJsonRpcFormatterState)
Initializes a new instance of the MessageFormatterDuplexPipeTracker class.
public MessageFormatterDuplexPipeTracker(JsonRpc jsonRpc, IJsonRpcFormatterState formatterState)
Parameters
jsonRpcJsonRpcThe JsonRpc instance that may be used to send or receive RPC messages related to IAsyncEnumerable<T>.
formatterStateIJsonRpcFormatterStateThe formatter that owns this tracker.
Properties
MultiplexingStream
Gets or sets the multiplexing stream used to create and accept channels.
public MultiplexingStream? MultiplexingStream { get; set; }
Property Value
Remarks
If this is null, some public methods will throw NotSupportedException.
Methods
Dispose()
public void Dispose()
Dispose(bool)
Disposes managed and native resources held by this instance.
protected virtual void Dispose(bool disposing)
Parameters
GetPipe(int?)
Creates an IDuplexPipe from a given token as it is received at the RPC server as a method argument.
[Obsolete("Use GetPipe(ulong?) instead.")]
public IDuplexPipe? GetPipe(int? token)
Parameters
tokenint?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- IDuplexPipe
The IDuplexPipe from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetPipe(ulong?)
Creates an IDuplexPipe from a given token as it is received at the RPC server as a method argument.
public IDuplexPipe? GetPipe(ulong? token)
Parameters
tokenulong?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- IDuplexPipe
The IDuplexPipe from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetPipeReader(int?)
Creates a PipeReader from a given token as it is received at the RPC server as a method argument.
[Obsolete("Use GetPipeReader(ulong?) instead.")]
public PipeReader? GetPipeReader(int? token)
Parameters
tokenint?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- PipeReader
The PipeReader from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetPipeReader(ulong?)
Creates a PipeReader from a given token as it is received at the RPC server as a method argument.
public PipeReader? GetPipeReader(ulong? token)
Parameters
tokenulong?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- PipeReader
The PipeReader from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetPipeWriter(int?)
Creates a PipeWriter from a given token as it is received at the RPC server as a method argument.
[Obsolete("Use GetPipeWriter(ulong?) instead.")]
public PipeWriter? GetPipeWriter(int? token)
Parameters
tokenint?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- PipeWriter
The PipeWriter from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetPipeWriter(ulong?)
Creates a PipeWriter from a given token as it is received at the RPC server as a method argument.
public PipeWriter? GetPipeWriter(ulong? token)
Parameters
tokenulong?The method argument, which was originally obtained by the client using the GetToken(IDuplexPipe?) method.
Returns
- PipeWriter
The PipeWriter from the token; or null if
tokenwas null.
Exceptions
- InvalidOperationException
Thrown if the token does not match up with an out of band channel offered by the client.
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor.
GetToken(IDuplexPipe?)
Creates a token to represent an IDuplexPipe as it is transmitted from the client to an RPC server as a method argument.
[Obsolete("Use GetULongToken instead.")]
public int? GetToken(IDuplexPipe? duplexPipe)
Parameters
duplexPipeIDuplexPipeThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.
GetToken(PipeReader?)
Creates a token to represent a PipeReader as it is transmitted from the client to an RPC server as a method argument.
[Obsolete("Use GetULongToken instead.")]
public int? GetToken(PipeReader? reader)
Parameters
readerPipeReaderThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.
GetToken(PipeWriter?)
Creates a token to represent a PipeWriter as it is transmitted from the client to an RPC server as a method argument.
[Obsolete("Use GetULongToken instead.")]
public int? GetToken(PipeWriter? writer)
Parameters
writerPipeWriterThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.
GetULongToken(IDuplexPipe?)
Creates a token to represent an IDuplexPipe as it is transmitted from the client to an RPC server as a method argument.
public ulong? GetULongToken(IDuplexPipe? duplexPipe)
Parameters
duplexPipeIDuplexPipeThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.
GetULongToken(PipeReader?)
Creates a token to represent a PipeReader as it is transmitted from the client to an RPC server as a method argument.
public ulong? GetULongToken(PipeReader? reader)
Parameters
readerPipeReaderThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.
GetULongToken(PipeWriter?)
Creates a token to represent a PipeWriter as it is transmitted from the client to an RPC server as a method argument.
public ulong? GetULongToken(PipeWriter? writer)
Parameters
writerPipeWriterThe client pipe that is to be shared with the RPC server. May be null.
Returns
Exceptions
- NotSupportedException
Thrown if no MultiplexingStream was provided to the constructor or when serializing a message without an ID property.