Skip to content

Class RpcHost

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

Accepts connections from a listener and turns each one into an DotBoxD.Services.Peer.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

objectRpcHost

IAsyncDisposable

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object, object), object.ToString()

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

public ValueTask DisposeAsync()

ValueTask

A task that represents the asynchronous dispose operation.

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

public RpcHost ForEachPeer(Action<RpcPeer> configure)

configure Action<RpcPeer>

RpcHost

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?)

Section titled “ 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)

listener IServerTransport

serializer ISerializer

options RpcPeerOptions?

RpcHost

public Task StartAsync(CancellationToken ct = default)

ct CancellationToken

Task

public Task StopAsync(CancellationToken ct = default)

ct CancellationToken

Task

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

public event EventHandler<RpcHostErrorEventArgs>? AcceptError

EventHandler<RpcHostErrorEventArgs>?

Raised after a connection is accepted and configured.

public event EventHandler<RpcPeerEventArgs>? PeerConnected

EventHandler<RpcPeerEventArgs>?

Raised when an accepted peer’s read loop ends.

public event EventHandler<RpcPeerEventArgs>? PeerDisconnected

EventHandler<RpcPeerEventArgs>?