Table of Contents

Class MultiplexingRelayServiceBroker

Namespace
Nerdbank.JsonRpc.BrokeredServices
Assembly
Nerdbank.JsonRpc.dll

Relays brokered services over channels on a caller-owned multiplexing stream.

public sealed class MultiplexingRelayServiceBroker : IRemoteServiceBroker, IShapeable<IRemoteServiceBroker>, IDisposable
Inheritance
MultiplexingRelayServiceBroker
Implements
Inherited Members

Constructors

MultiplexingRelayServiceBroker(IServiceBroker, MultiplexingStream)

Initializes a new instance of the MultiplexingRelayServiceBroker class.

public MultiplexingRelayServiceBroker(IServiceBroker broker, MultiplexingStream multiplexer)

Parameters

broker IServiceBroker

The broker, including per-registration capabilities.

multiplexer MultiplexingStream

The caller-owned stream carrying service channels.

Properties

ConnectionTimeout

Gets the time allowed for clients to accept an offered channel.

public TimeSpan ConnectionTimeout { get; init; }

Property Value

TimeSpan

Logger

Gets the logger used to observe channel and cleanup failures.

public ILogger<MultiplexingRelayServiceBroker> Logger { get; init; }

Property Value

ILogger<MultiplexingRelayServiceBroker>

Methods

CancelServiceRequestAsync(Guid, CancellationToken)

Releases an endpoint that the caller cannot or will not connect to.

public Task CancelServiceRequestAsync(Guid requestId, CancellationToken cancellationToken)

Parameters

requestId Guid

The allocated request identity.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

A task tracking cleanup.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetCapabilitiesAsync(ServiceMoniker, CancellationToken)

Queries registration capabilities without activating a service.

public Task<IReadOnlyList<string>?> GetCapabilitiesAsync(ServiceMoniker moniker, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested service.

cancellationToken CancellationToken

Cancels discovery.

Returns

Task<IReadOnlyList<string>>

Stable capability identifiers, or null when unavailable.

HandshakeAsync(RemoteServiceConnections, CancellationToken)

Negotiates a broker protocol version and service-channel transport.

public Task<int> HandshakeAsync(RemoteServiceConnections connections, CancellationToken cancellationToken)

Parameters

connections RemoteServiceConnections

The client's supported transports.

cancellationToken CancellationToken

Cancels negotiation.

Returns

Task<int>

The selected protocol version. Unsupported transport sets fail explicitly.

RequestServiceChannelAsync(ServiceMoniker, RemoteServiceActivationOptions, CancellationToken)

Allocates a service endpoint and returns its registration's actual capabilities.

public Task<RemoteServiceConnectionInfo?> RequestServiceChannelAsync(ServiceMoniker moniker, RemoteServiceActivationOptions options, CancellationToken cancellationToken)

Parameters

moniker ServiceMoniker

The requested service.

options RemoteServiceActivationOptions

Transferable activation arguments and cultures.

cancellationToken CancellationToken

Cancels allocation.

Returns

Task<RemoteServiceConnectionInfo>

The connection instructions, or null if unavailable.

Events

AvailabilityChanged

Occurs when queried services may have changed.

public event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged

Event Type

EventHandler<BrokeredServicesChangedEventArgs>