namespace ZB.MOM.WW.MxGateway.Server.Workers;
public sealed class WorkerClientConnection
{
/// Initializes a new worker client connection.
/// Identifier of the session.
/// Worker handshake nonce.
/// Named pipe stream for IPC communication.
/// Frame protocol serialization options.
/// Worker process handle, if available.
public WorkerClientConnection(
string sessionId,
string nonce,
Stream stream,
WorkerFrameProtocolOptions frameOptions,
WorkerProcessHandle? processHandle = null)
{
if (string.IsNullOrWhiteSpace(sessionId))
{
throw new ArgumentException("Session id is required.", nameof(sessionId));
}
if (string.IsNullOrWhiteSpace(nonce))
{
throw new ArgumentException("Worker nonce is required.", nameof(nonce));
}
SessionId = sessionId;
Nonce = nonce;
Stream = stream ?? throw new ArgumentNullException(nameof(stream));
FrameOptions = frameOptions ?? throw new ArgumentNullException(nameof(frameOptions));
ProcessHandle = processHandle;
}
/// The session ID associated with this connection.
public string SessionId { get; }
/// The nonce used for handshaking with the worker.
public string Nonce { get; }
/// The named pipe stream for IPC communication.
public Stream Stream { get; }
/// The frame protocol options for serialization.
public WorkerFrameProtocolOptions FrameOptions { get; }
/// The worker process handle, if available.
public WorkerProcessHandle? ProcessHandle { get; }
}