SbeWriteBuffer

StockSharp.Server.Sbe

Helpers for serializing an SBE message into a per-session write buffer that grows on overflow instead of dropping the message and disconnecting the client.

Methods

Grow(byte[], int) : byte[]

Returns a buffer at least bytes long. If the existing buffer is already large enough it is returned unchanged; otherwise a new buffer is allocated by doubling capacity until it covers , capped at MaxWriteBufferSize.

buffer
Current buffer (may be null).
minSize
Minimum required size in bytes.

Returns: A buffer whose length is at least .

IsOverflow(Exception, int, int) : bool

Recognizes the span-overflow exceptions thrown by the SBE serializer and computes a target size to grow to. A dedicated SbeBufferTooSmallException supplies an exact size; generic span overflows fall back to doubling.

Serialize(ClientSbeSession, Func<SbeRecordSerializer, byte[], int>) : int

Serializes a message into the session write buffer, growing the buffer and retrying on overflow. Returns the number of bytes written. The (possibly reallocated) buffer is available via WriteBuffer.

session
Target session whose write buffer is used.
serialize
Serialize delegate: writes into the buffer, returns written length.

Returns: Number of bytes written into the session buffer.

Fields

InitialWriteBufferSize : int

Default initial size of a session write buffer.

MaxWriteBufferSize : int

Hard upper bound for a single SBE frame. A frame that does not fit even after growing to this size is treated as a genuine error and re-thrown, rather than looping forever on reallocation.