Class AdapterNamedPipeClient

Namespace
MirrorPulse.Adapter.Sdk
Assembly
MirrorPulse.Adapter.Sdk.dll

Connects a Worker to the local named pipe opened by the MirrorPulse Host.

public sealed class AdapterNamedPipeClient : IAsyncDisposable
Inheritance
AdapterNamedPipeClient
Implements
Inherited Members

Remarks

Use AdapterControlChannel to add the Worker session and protocol checks to framed I/O.

Methods

ConnectAsync(string, TimeSpan, CancellationToken)

Opens a duplex connection to the supplied local named pipe.

public static Task<AdapterNamedPipeClient> ConnectAsync(string pipeName, TimeSpan timeout, CancellationToken cancellationToken = default)

Parameters

pipeName string

The pipe name supplied in the Worker launch arguments.

timeout TimeSpan

The maximum connection wait, or InfiniteTimeSpan.

cancellationToken CancellationToken

Cancels the connection attempt.

Returns

Task<AdapterNamedPipeClient>

The connected client. Dispose it when the Worker session ends.

Exceptions

ArgumentOutOfRangeException

The timeout is negative or above the supported millisecond range.

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask

ReadFrameAsync(CancellationToken)

Reads one complete bounded frame, including when the pipe divides it across reads.

public ValueTask<byte[]> ReadFrameAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<byte[]>

Exceptions

InvalidDataException

The frame length is above the SDK limit.

EndOfStreamException

The pipe closed before a complete frame arrived.

WriteFrameAsync(ReadOnlyMemory<byte>, CancellationToken)

Writes a little-endian length prefix and one framed payload.

public ValueTask WriteFrameAsync(ReadOnlyMemory<byte> payload, CancellationToken cancellationToken = default)

Parameters

payload ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The caller serializes writes. If a write is interrupted, close the session before sending another frame.