Table of Contents

Delegate FlushSink

Namespace
sofab
Assembly
SofaBuffers.dll

Sink that receives buffered bytes when an OStream's buffer fills (or when Flush() is called).

public delegate void FlushSink(byte[] data, int offset, int length)

Parameters

data byte[]

the encoder's active buffer

offset int

start of the pending bytes

length int

number of pending bytes

Remarks

This is a delegate, so a sink can be written as a lambda or a method group โ€” for example stream.Write for a Stream. Implementing it lets a message larger than the output buffer (or larger than RAM) be streamed out incrementally: the encoder hands the sink each full buffer and then resumes at the start of the buffer.

The array is owned by the encoder and is reused after the call returns; a sink that needs to retain the bytes must copy them.

What returning means (CORELIB_PLAN ยง5.1). Returning without installing a buffer says the sink copied: the array stays the active buffer and the encoder resumes writing into it at offset 0. A sink that takes the buffer โ€” passes it to a transport, queues it for an asynchronous write โ€” MUST install a replacement before returning, with BufferSet(byte[], int), and the encoder resumes at that call's start offset. Installing the same array again is an installation like any other, which is how a sink reserves framing-header room in every flushed packet.