Hmp1WorkloadAdapter
Namespace: Hex1b
Assembly: Hex1b.dll
A workload adapter that connects to a remote muxer server over the Hex1b Muxer Protocol (HMP).
public sealed class Hmp1WorkloadAdapter : IHex1bTerminalWorkloadAdapter, IAsyncDisposableInheritance
Object → Hmp1WorkloadAdapter
Implements
Constructors
Hmp1WorkloadAdapter(Func<CancellationToken, Task<Stream>>)
Creates a muxer workload adapter that connects via the given stream factory.
Parameters:
streamFactory(Func<CancellationToken, Stream>>): Factory that creates a bidirectional stream to the server.
public Hmp1WorkloadAdapter(Func<CancellationToken, Task<Stream>> streamFactory)Hmp1WorkloadAdapter(Stream)
Creates a muxer workload adapter with an already-connected stream.
Parameters:
stream(Stream): A bidirectional stream connected to the server.
public Hmp1WorkloadAdapter(Stream stream)Properties
RemoteHeight
Gets the remote terminal height reported in the Hello frame.
Returns: Int32
public int RemoteHeight { get; }RemoteWidth
Gets the remote terminal width reported in the Hello frame.
Returns: Int32
public int RemoteWidth { get; }Methods
ConnectAsync(CancellationToken)
Connects to the server, reads the Hello and StateSync frames, and starts the background read pump.
Parameters:
ct(CancellationToken):
Returns: Task
public Task ConnectAsync(CancellationToken ct)DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Returns: ValueTask
A task that represents the asynchronous dispose operation.
public ValueTask DisposeAsync()ReadOutputAsync(CancellationToken)
Read output FROM the workload (ANSI sequences to display). The terminal calls this to get data to parse and send to presentation. Returns empty when workload has no more output (should be called in a loop).
Parameters:
ct(CancellationToken):
Returns: ValueTask<Byte>>
public ValueTask<ReadOnlyMemory<byte>> ReadOutputAsync(CancellationToken ct = default)ResizeAsync(int, int, CancellationToken)
Notify workload of terminal resize.
Parameters:
width(Int32):height(Int32):ct(CancellationToken):
Returns: ValueTask
public ValueTask ResizeAsync(int width, int height, CancellationToken ct = default)WriteInputAsync(ReadOnlyMemory<byte>, CancellationToken)
Write input TO the workload (raw bytes from keyboard/mouse). The terminal calls this when it receives input from the presentation layer.
Parameters:
data(ReadOnlyMemory<Byte>):ct(CancellationToken):
Returns: ValueTask
public ValueTask WriteInputAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)Events
Disconnected
Raised when workload has disconnected/exited.
Returns: Action
public event Action? DisconnectedRemarks
This adapter reads terminal output from a remote server and forwards local keyboard input and resize events to it. On connection, the server sends a Hello frame with dimensions and a StateSync frame with the current screen content.
The adapter is transport-agnostic: provide any bidirectional (Unix domain socket, TCP, named pipe, etc.).