Table of Contents

Class RpcHost

Namespace
DotBoxD.Services.Server
Assembly
DotBoxD.Services.dll

Accepts connections from a listener and turns each one into an RpcPeer. The accept loop that used to live inside the server now lives here, and its output is peers: because each connection is a full peer, a host can both provide services to and call back into the peers that connect to it.

public sealed class RpcHost : IAsyncDisposable
Inheritance
RpcHost
Implements
Inherited Members

Methods

DisposeAsync()

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

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

ForEachPeer(Action<RpcPeer>)

Registers configuration that runs for every accepted peer before its read loop starts. Use it to Provide<TService>(TService) exports (and optionally Get<TService>() proxies to call the peer back).

public RpcHost ForEachPeer(Action<RpcPeer> configure)

Parameters

configure Action<RpcPeer>

Returns

RpcHost

Remarks

Services provided here are callable by any accepted peer. DotBoxD does not add authentication or authorization; enforce access control at the transport or application layer.

Listen(IServerTransport, ISerializer, RpcPeerOptions?)

Creates a host that turns every accepted connection into a peer.

public static RpcHost Listen(IServerTransport listener, ISerializer serializer, RpcPeerOptions? options = null)

Parameters

listener IServerTransport
serializer ISerializer
options RpcPeerOptions

Returns

RpcHost

StartAsync(CancellationToken)

public Task StartAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

StopAsync(CancellationToken)

public Task StopAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

Events

AcceptError

Raised when the host accept loop catches a non-cancellation exception.

public event EventHandler<RpcHostErrorEventArgs>? AcceptError

Event Type

EventHandler<RpcHostErrorEventArgs>

PeerConnected

Raised after a connection is accepted and configured.

public event EventHandler<RpcPeerEventArgs>? PeerConnected

Event Type

EventHandler<RpcPeerEventArgs>

PeerDisconnected

Raised when an accepted peer's read loop ends.

public event EventHandler<RpcPeerEventArgs>? PeerDisconnected

Event Type

EventHandler<RpcPeerEventArgs>