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
pipeNamestringThe pipe name supplied in the Worker launch arguments.
timeoutTimeSpanThe maximum connection wait, or InfiniteTimeSpan.
cancellationTokenCancellationTokenCancels 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
ReadFrameAsync(CancellationToken)
Reads one complete bounded frame, including when the pipe divides it across reads.
public ValueTask<byte[]> ReadFrameAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
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
payloadReadOnlyMemory<byte>cancellationTokenCancellationToken
Returns
Remarks
The caller serializes writes. If a write is interrupted, close the session before sending another frame.