Skip to content

Class PluginConnectionHost<TConnection>

Namespace: DotBoxD.Pushdown.Services
Assembly: DotBoxD.Pushdown.Services.dll

Accepts ONE plugin connection and owns the per-connection trust-boundary lifecycle: it listens for the connecting peer, mints a DotBoxD.Plugins.PluginSession for it, runs configure to provision that peer (provide host services over the session and return the per-connection object callers await), and disposes the session — revoking and unregistering the kernels that peer owned — when the peer disconnects OR the host is stopped/disposed.

This is the per-connection IPC ceremony every plugin host used to hand-write. Forgetting the dispose-on-disconnect step silently leaks a peer's kernels, so the framework owns it; the host is left with only the genuinely connection-specific work of choosing which services to provide. The helper is opt-in: everything it does is reproducible with public API (`DotBoxD.Pushdown.Services.RpcMessagePackIpc.Listen(DotBoxD.Services.Transport.IServerTransport,System.Action{DotBoxD.Services.Peer.RpcPeer},DotBoxD.Services.Peer.RpcPeerOptions)` / `DotBoxD.Plugins.PluginServer.CreateSession` / peer.Provide / peer.Disconnected).

public sealed class PluginConnectionHost<TConnection> : IAsyncDisposable

TConnection

The per-connection object configure returns (e.g. the control service).

objectPluginConnectionHost<TConnection>

IAsyncDisposable

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

Completes when a plugin connects, yielding the object configure returned for it; faults if configure throws; cancels if the host is stopped/disposed before any plugin connects.

public Task<TConnection> Connected { get; }

Task<TConnection>

Completes when the connected plugin drops (after its session has been disposed) OR the host is stopped/disposed.

public Task Disconnected { get; }

Task

The named pipe the plugin peer dials, or empty when started over a non-pipe transport.

public string PipeName { get; }

string

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.

StartAsync(PluginServer, string, Func<RpcPeer, PluginSession, TConnection>, RpcPeerOptions?)

Section titled “ StartAsync(PluginServer, string, Func<RpcPeer, PluginSession, TConnection>, RpcPeerOptions?)”

Starts listening on pipeName (a convenience over the transport overload; keeps the high-entropy pipe-name validation). For the connecting peer the host mints a session and invokes configure(peer, session) — where the caller provides its host services over the session and returns the per-connection object surfaced by DotBoxD.Pushdown.Services.PluginConnectionHost.Connected. The session is disposed automatically when the peer disconnects or the host is stopped/disposed.

public static Task<PluginConnectionHost<TConnection>> StartAsync(PluginServer server, string pipeName, Func<RpcPeer, PluginSession, TConnection> configure, RpcPeerOptions? options = null)

server PluginServer

pipeName string

configure Func<RpcPeer, PluginSession, TConnection>

options RpcPeerOptions?

Task<PluginConnectionHost<TConnection>>

StartAsync(PluginServer, IServerTransport, Func<RpcPeer, PluginSession, TConnection>, RpcPeerOptions?)

Section titled “ StartAsync(PluginServer, IServerTransport, Func<RpcPeer, PluginSession, TConnection>, RpcPeerOptions?)”

Starts listening over any transport (TCP, in-memory, …) — the transport-agnostic form, so a host is not locked to named pipes. Same per-connection lifecycle as the pipe overload; DotBoxD.Pushdown.Services.PluginConnectionHost.PipeName is empty.

public static Task<PluginConnectionHost<TConnection>> StartAsync(PluginServer server, IServerTransport transport, Func<RpcPeer, PluginSession, TConnection> configure, RpcPeerOptions? options = null)

server PluginServer

transport IServerTransport

configure Func<RpcPeer, PluginSession, TConnection>

options RpcPeerOptions?

Task<PluginConnectionHost<TConnection>>

Stops accepting connections and disposes the connected plugin’s session. A local stop does not raise the peer’s Disconnected event, so this is the cleanup path when the host shuts the listener down while a plugin is still connected; it also completes DotBoxD.Pushdown.Services.PluginConnectionHost.Connected/DotBoxD.Pushdown.Services.PluginConnectionHost.Disconnected so no awaiter is left hanging.

public Task StopAsync()

Task