Table of Contents

Class RemoteLocalHandlerRegistry

Namespace
DotBoxD.Plugins.Runtime.Hooks
Assembly
DotBoxD.Plugins.dll

Client-side registry for remote RunLocal terminals. A remote server.Hooks.On<TEvent>().Where(..).Select(..).RunLocal(λ) chain lowers only its Where/Select stages to verified IR that filters and projects server-side; the projected value is pushed back over the control-plane callback per passing event. This registry holds the native RunLocal delegate (real host C#, never lowered), keyed by the subscription id returned at install time, and decodes each pushed payload back to the projected CLR type before invoking that delegate.

public sealed class RemoteLocalHandlerRegistry
Inheritance
RemoteLocalHandlerRegistry
Inherited Members

Remarks

The decode mirrors the server-extension request/response path in reverse: the same KernelRpcBinaryCodec/KernelRpcValueConverter/KernelRpcMarshaller converters carry the value, so the supported projection types are exactly the wire-eligible set (bool, int, long, double, string, enums, lists/arrays, and DTO records).

Methods

Clear()

Removes all registered handlers. Called when the plugin connection tears down (session disposed / peer disconnected) so a dropped plugin's callbacks do not linger.

public void Clear()

DispatchAsync(string, ReadOnlyMemory<byte>, HookContext, CancellationToken)

Decodes a server-pushed projected payload back to the projected CLR type and invokes the registered native delegate. context is the client-side HookContext the delegate runs against. Throws if no handler is registered for subscriptionId.

public ValueTask DispatchAsync(string subscriptionId, ReadOnlyMemory<byte> projectedValue, HookContext context, CancellationToken cancellationToken = default)

Parameters

subscriptionId string
projectedValue ReadOnlyMemory<byte>
context HookContext
cancellationToken CancellationToken

Returns

ValueTask

DispatchResultAsync(string, ReadOnlyMemory<byte>, HookContext, CancellationToken)

public ValueTask<byte[]> DispatchResultAsync(string subscriptionId, ReadOnlyMemory<byte> contextValue, HookContext context, CancellationToken cancellationToken = default)

Parameters

subscriptionId string
contextValue ReadOnlyMemory<byte>
context HookContext
cancellationToken CancellationToken

Returns

ValueTask<byte[]>

RegisterResult<TContext, TResult>(string, Func<TContext, HookContext, CancellationToken, ValueTask<TResult>>)

public IDisposable RegisterResult<TContext, TResult>(string subscriptionId, Func<TContext, HookContext, CancellationToken, ValueTask<TResult>> handler) where TResult : struct, IHookResult

Parameters

subscriptionId string
handler Func<TContext, HookContext, CancellationToken, ValueTask<TResult>>

Returns

IDisposable

Type Parameters

TContext
TResult

RegisterResult<TContext, TResult>(string, Func<TContext, HookContext, TResult>)

public IDisposable RegisterResult<TContext, TResult>(string subscriptionId, Func<TContext, HookContext, TResult> handler) where TResult : struct, IHookResult

Parameters

subscriptionId string
handler Func<TContext, HookContext, TResult>

Returns

IDisposable

Type Parameters

TContext
TResult

Register<TProjected>(string, Func<TProjected, HookContext, ValueTask>)

Registers the native terminal delegate for a lowered local chain. TProjected is the type produced by the chain's final Select (or the event type when there is no projection — a whole-event chain). Idempotent: re-registering the same subscriptionId replaces the previous handler, so a plugin that reconnects and re-installs with a reused id does not throw. Returns a token that unregisters this handler when disposed.

public IDisposable Register<TProjected>(string subscriptionId, Func<TProjected, HookContext, ValueTask> handler)

Parameters

subscriptionId string
handler Func<TProjected, HookContext, ValueTask>

Returns

IDisposable

Type Parameters

TProjected

Register<TProjected>(string, Func<TProjected, HookContext, ValueTask>, Func<KernelRpcValue, TProjected>)

Registers the native terminal delegate alongside a generated reflection-free decoder that reads TProjected straight off the pushed KernelRpcValue's typed fields — no SandboxValue intermediate, no boxing, no reflection. Emitted by the plugin generator for wire-eligible projected types; Register<TProjected>(string, Func<TProjected, HookContext, ValueTask>) remains the fallback for the rest. Idempotent in the same way as the 2-arg overload.

public IDisposable Register<TProjected>(string subscriptionId, Func<TProjected, HookContext, ValueTask> handler, Func<KernelRpcValue, TProjected> decoder)

Parameters

subscriptionId string
handler Func<TProjected, HookContext, ValueTask>
decoder Func<KernelRpcValue, TProjected>

Returns

IDisposable

Type Parameters

TProjected

Register<TProjected>(string, Func<TProjected, HookContext, ValueTask>, Func<ReadOnlyMemory<byte>, TProjected>)

Registers a generated decoder that reads directly from the pushed binary payload. This is the fastest generated path because dispatch does not materialize an intermediate KernelRpcValue tree.

public IDisposable Register<TProjected>(string subscriptionId, Func<TProjected, HookContext, ValueTask> handler, Func<ReadOnlyMemory<byte>, TProjected> decoder)

Parameters

subscriptionId string
handler Func<TProjected, HookContext, ValueTask>
decoder Func<ReadOnlyMemory<byte>, TProjected>

Returns

IDisposable

Type Parameters

TProjected

Unregister(string)

Removes the handler for subscriptionId. Returns true if one was present.

public bool Unregister(string subscriptionId)

Parameters

subscriptionId string

Returns

bool