Skip to content
Auto
Products

NamedPipeRequestEventArgs

Namespace: TagBites.Pipes
Assembly: TagBites.Pipes.dll
Product: TagBites.Pipes v. 1.2.0

Provides data for the NamedPipeServer.Request event.

public class NamedPipeRequestEventArgs : System.EventArgs

Inheritance: EventArgs → NamedPipeRequestEventArgs

NamedPipeRequestEventArgs(NamedPipeConnectionContext, string, string)

Section titled “NamedPipeRequestEventArgs(NamedPipeConnectionContext, string, string)”

Initializes a new instance of the NamedPipeRequestEventArgs class.

public NamedPipeRequestEventArgs(NamedPipeConnectionContext context, string address, string message)

Gets the address of the request, which names the operation the client asks for.

public string Address { get; }

string

Gets the context of the connection the request arrived on.

public NamedPipeConnectionContext Context { get; }

NamedPipeConnectionContext

Gets the message of the request.

public string Message { get; }

string

Gets the message of the request as a stream.

public Stream MessageStream { get; }

Stream

Valid while the handler runs. Whatever the handler leaves unread is skipped, so the next request still starts at a message boundary.

Gets or sets the text sent back to the client.

public string Response { get; set; }

string

null reaches the client as an empty string.

Gets or sets the task the server waits for before it reads the response.

public Task ResultTask { get; set; }

Task

Set this to handle a request asynchronously. The handler assigns the task and returns, and the server reads the response once the task completes. An exception from the task reaches the client the same way as one thrown by the handler itself.

Answers with whatever the callback writes into the stream, without holding the whole response in memory.

public void SetResponse(Func<Stream, Task> writeResponse)

The connection has to be on encoding version 3, because earlier versions carry text only. A failure after the callback started writing breaks the connection, since the answer is already on its way. Read MessageStream in the handler, not in this callback: the request is consumed to the end before the answer starts, so by then it is empty.