Interface IMultiplexedConnection
- Namespace
- IceRpc.Transports
- Assembly
- IceRpc.dll
Represents a transport connection created by a multiplexed transport.
public interface IMultiplexedConnection : IAsyncDisposable
- Inherited Members
Remarks
The IceRPC core implementation uses this interface. It provides the following guarantees:
- The ConnectAsync(CancellationToken) method is always called first and once. No other methods are called until it completes.
- The AcceptStreamAsync(CancellationToken) method is never called concurrently.
- The CreateStreamAsync(bool, CancellationToken) method can be called concurrently.
- The AcceptStreamAsync(CancellationToken) and CreateStreamAsync(bool, CancellationToken) methods can be called concurrently.
- The CloseAsync(MultiplexedConnectionCloseError, CancellationToken) method is called once but not while an AcceptStreamAsync(CancellationToken) call is in progress. It can be called while a CreateStreamAsync(bool, CancellationToken) call is in progress.
- The CreateStreamAsync(bool, CancellationToken) and AcceptStreamAsync(CancellationToken) methods are never called after a CloseAsync(MultiplexedConnectionCloseError, CancellationToken) call.
- The DisposeAsync() method can be called while a CreateStreamAsync(bool, CancellationToken) call is in progress. It is never called while AcceptStreamAsync(CancellationToken) or CloseAsync(MultiplexedConnectionCloseError, CancellationToken) are in progress.
Methods
AcceptStreamAsync(CancellationToken)
Accepts a remote stream.
ValueTask<IMultiplexedStream> AcceptStreamAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<IMultiplexedStream>
A task that completes successfully with the remote stream. This task can also complete with one of the following exceptions:
- IceRpcException if the transport reported an error.
- OperationCanceledException if cancellation was requested through the cancellation token.
Exceptions
- InvalidOperationException
Thrown if ConnectAsync(CancellationToken) did not complete successfully prior to this call.
- IceRpcException
Thrown if the connection is closed.
- ObjectDisposedException
Thrown if the connection has been disposed.
CloseAsync(MultiplexedConnectionCloseError, CancellationToken)
Closes the connection.
Task CloseAsync(MultiplexedConnectionCloseError closeError, CancellationToken cancellationToken)
Parameters
closeError
MultiplexedConnectionCloseErrorThe error to transmit to the peer.
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task
A task that completes once the connection closure completes successfully. This task can also complete with one of the following exceptions:
- IceRpcException if the transport reported an error.
- OperationCanceledException if cancellation was requested through the cancellation token.
Exceptions
- InvalidOperationException
Thrown if ConnectAsync(CancellationToken) did not complete successfully prior to this call, or if this method is called more than once.
- ObjectDisposedException
Thrown if the connection has been disposed.
ConnectAsync(CancellationToken)
Connects this connection.
Task<TransportConnectionInformation> ConnectAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task<TransportConnectionInformation>
A task that completes successfully with transport connection information when the connection is established. This task can also complete with one of the following exceptions:
- AuthenticationException if authentication failed.
- IceRpcException if the transport reported an error.
- OperationCanceledException if cancellation was requested through the cancellation token.
Exceptions
- InvalidOperationException
Thrown if this method is called more than once.
- ObjectDisposedException
Thrown if the connection has been disposed.
CreateStreamAsync(bool, CancellationToken)
Creates a local stream. The creation will block if the maximum number of unidirectional or bidirectional streams prevents creating the new stream.
ValueTask<IMultiplexedStream> CreateStreamAsync(bool bidirectional, CancellationToken cancellationToken)
Parameters
bidirectional
boolcancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<IMultiplexedStream>
The task that completes on the local stream is created.
Exceptions
- InvalidOperationException
Thrown if ConnectAsync(CancellationToken) did not complete successfully prior to this call.
- IceRpcException
Thrown if the connection is closed.
- ObjectDisposedException
Thrown if the connection has been disposed.