Table of Contents

Class RemoteServiceBroker

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

Adapts a remote broker control contract to typed local service acquisition.

public sealed class RemoteServiceBroker : IServiceBroker, IDisposable
Inheritance
RemoteServiceBroker
Implements
Inherited Members
Extension Methods

Properties

Logger

Gets or sets the client broker logger.

public ILogger<RemoteServiceBroker> Logger { get; set; }

Property Value

ILogger<RemoteServiceBroker>

Methods

ConnectAsync(IRemoteServiceBroker, MultiplexingStream?, CancellationToken)

Adapts a connected control contract with caller-owned multiplexed service channels.

public static Task<RemoteServiceBroker> ConnectAsync(IRemoteServiceBroker remote, MultiplexingStream? multiplexer, CancellationToken cancellationToken = default)

Parameters

remote IRemoteServiceBroker

The caller-owned control contract.

multiplexer MultiplexingStream

The caller-owned multiplexer, or null for IPC.

cancellationToken CancellationToken

Cancels negotiation.

Returns

Task<RemoteServiceBroker>

The initialized broker.

ConnectAsync(IRemoteServiceBroker, CancellationToken)

Adapts an already connected remote control contract.

public static Task<RemoteServiceBroker> ConnectAsync(IRemoteServiceBroker remote, CancellationToken cancellationToken = default)

Parameters

remote IRemoteServiceBroker

The contract, whose lifetime remains caller-owned.

cancellationToken CancellationToken

Cancels negotiation.

Returns

Task<RemoteServiceBroker>

The initialized broker.

ConnectAsync(IDuplexPipe, JsonRpcDescriptor<IRemoteServiceBroker>?, ServiceRpcContext?, CancellationToken)

Attaches a generated broker proxy, subscribes to events, starts dispatch, and negotiates.

public static Task<RemoteServiceBroker> ConnectAsync(IDuplexPipe pipe, JsonRpcDescriptor<IRemoteServiceBroker>? descriptor = null, ServiceRpcContext? context = null, CancellationToken cancellationToken = default)

Parameters

pipe IDuplexPipe

The broker control channel, whose ownership transfers when the connection is constructed, including when initialization subsequently fails.

descriptor JsonRpcDescriptor<IRemoteServiceBroker>

The agreed control descriptor, or the framework default.

context ServiceRpcContext

The infrastructure for the control connection and subsequent service connections.

cancellationToken CancellationToken

Cancels initialization.

Returns

Task<RemoteServiceBroker>

The initialized broker, which owns its control connection.

ConnectAsync(IDuplexPipe, MultiplexingStream, JsonRpcDescriptor<IRemoteServiceBroker>?, ServiceRpcContext?, CancellationToken)

Connects a broker control pipe with a separate caller-owned multiplexer carrying opaque service transports.

public static Task<RemoteServiceBroker> ConnectAsync(IDuplexPipe pipe, MultiplexingStream multiplexer, JsonRpcDescriptor<IRemoteServiceBroker>? descriptor = null, ServiceRpcContext? context = null, CancellationToken cancellationToken = default)

Parameters

pipe IDuplexPipe

The broker control channel, whose ownership transfers when the connection is constructed.

multiplexer MultiplexingStream

The caller-owned transport multiplexer. It is never used for service resource marshalling.

descriptor JsonRpcDescriptor<IRemoteServiceBroker>

The agreed control descriptor, or the framework default.

context ServiceRpcContext

Runtime infrastructure for the control and service connections.

cancellationToken CancellationToken

Cancels initialization.

Returns

Task<RemoteServiceBroker>

The initialized broker, which owns its control connection but not the transport multiplexer.

Dispose()

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

public void Dispose()

GetCapabilitiesAsync(ServiceMoniker, CancellationToken)

Gets the capabilities of the selected registration without activating it.

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

Parameters

moniker ServiceMoniker

The requested service.

cancellationToken CancellationToken

Cancels lookup.

Returns

ValueTask<IReadOnlyList<string>>

Stable capability identifiers, or null when no registration exists.

GetConnectionAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)

Acquires a channel and capabilities from the same winning registration.

public ValueTask<BrokeredServiceConnection?> GetConnectionAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested identity.

options ServiceActivationOptions

Options for the activation.

cancellationToken CancellationToken

Cancels acquisition.

Returns

ValueTask<BrokeredServiceConnection>

The caller-owned connection, or null if unavailable.

GetPipeAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)

Acquires a service's raw RPC pipe.

public ValueTask<IDuplexPipe?> GetPipeAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)

Parameters

moniker ServiceMoniker

The requested service.

options ServiceActivationOptions

Options for this activation.

cancellationToken CancellationToken

Cancels this request.

Returns

ValueTask<IDuplexPipe>

A caller-owned pipe, or null if the service is unavailable. Complete both ends when finished.

GetProxyAsync<T>(IJsonRpcDescriptor<T>, ServiceActivationOptions, CancellationToken)

Acquires a service proxy whose type is inferred from its descriptor.

public ValueTask<T?> GetProxyAsync<T>(IJsonRpcDescriptor<T> descriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default) where T : class

Parameters

descriptor IJsonRpcDescriptor<T>

The descriptor, including generated proxy support.

options ServiceActivationOptions

Options for this activation.

cancellationToken CancellationToken

Cancels this request.

Returns

ValueTask<T>

A caller-owned proxy, or null if the service is unavailable.

Type Parameters

T

The service interface.

Events

AvailabilityChanged

Occurs when previously queried service availability may have changed.

public event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged

Event Type

EventHandler<BrokeredServicesChangedEventArgs>