Table of Contents

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:

<ul><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.ConnectAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> method is always called first and once. No other methods are
called until it completes.</li><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.AcceptStreamAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> method is never called concurrently.</li><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.CreateStreamAsync(System.Boolean%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> method can be called concurrently.</li><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.AcceptStreamAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> and <xref href="IceRpc.Transports.IMultiplexedConnection.CreateStreamAsync(System.Boolean%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> methods can be called
concurrently.</li><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.CloseAsync(IceRpc.Transports.MultiplexedConnectionCloseError%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> method is called once but not while an <xref href="IceRpc.Transports.IMultiplexedConnection.AcceptStreamAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> call is in progress. It can be called while a <xref href="IceRpc.Transports.IMultiplexedConnection.CreateStreamAsync(System.Boolean%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> call is
in progress.</li><li>The <xref href="IceRpc.Transports.IMultiplexedConnection.CreateStreamAsync(System.Boolean%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> and <xref href="IceRpc.Transports.IMultiplexedConnection.AcceptStreamAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> methods are never
called after a <xref href="IceRpc.Transports.IMultiplexedConnection.CloseAsync(IceRpc.Transports.MultiplexedConnectionCloseError%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> call.</li><li>The <xref href="System.IAsyncDisposable.DisposeAsync" data-throw-if-not-resolved="false"></xref> method can be called while a <xref href="IceRpc.Transports.IMultiplexedConnection.CreateStreamAsync(System.Boolean%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> call is in progress. It is never called while <xref href="IceRpc.Transports.IMultiplexedConnection.AcceptStreamAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> or <xref href="IceRpc.Transports.IMultiplexedConnection.CloseAsync(IceRpc.Transports.MultiplexedConnectionCloseError%2cSystem.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> are in progress.</li></ul>

Methods

AcceptStreamAsync(CancellationToken)

Accepts a remote stream.

ValueTask<IMultiplexedStream> AcceptStreamAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

ValueTask<IMultiplexedStream>

A task that completes successfully with the remote stream.

Remarks

The returned task can also complete with one of the following exceptions:

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 MultiplexedConnectionCloseError

The error to transmit to the peer.

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task

A task that completes once the connection closure completes successfully.

Remarks

The returned task can also complete with one of the following exceptions:

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 CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task<TransportConnectionInformation>

A task that completes successfully with transport connection information when the connection is established.

Remarks

The returned task can also complete with one of the following exceptions:

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 bool

true to create a bidirectional stream, otherwise, false.

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

ValueTask<IMultiplexedStream>

A task that completes successfully with the local stream.

Remarks

The returned task can also complete with one of the following exceptions:

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.