ConnectionFrameHelper
class
Namespace: Orleans.Runtime.Messaging
Provides framing utilities for connection middleware authors.
Wire format per frame: [4-byte LE length] [1-byte frame type] [payload]. The length field equals 1 + payload.Length.
Connection middlewares should follow the Microsoft.AspNetCore.Connections.ConnectionDelegate pipeline pattern (like TLS) and register via SiloConnectionOptions or ClientConnectionOptions. Use these helpers for structured frame I/O within your middleware.
This helper is optional. Middleware authors who need custom protocols can read/write directly from context.Transport.Input (PipeReader) and context.Transport.Output (PipeWriter) without using this class.
public static class ConnectionFrameHelperMethods
ReadFrameAsync(ConnectionContext, CancellationToken, int)Reads a single frame from the connection.ReadLengthPrefixedString(byte[], int)Reads a length-prefixed UTF-8 string from a payload byte array.WriteFrameAsync(ConnectionContext, byte, Action<IBufferWriter<byte>>, CancellationToken)Writes a frame using zero-copy framing viaOrleans.Runtime.Messaging.PrefixingBufferWriter. ThewritePayloaddelegate writes payload directly into the transport pipe buffer.WriteFrameAsync(ConnectionContext, byte, byte[], CancellationToken)Writes a frame with the given type and raw payload bytes.WriteLengthPrefixedString(IBufferWriter<byte>, string)Writes a length-prefixed UTF-8 string (4-byte LE length + bytes) into a buffer.
Fields
DefaultMaxFrameLengthDefault maximum frame length (1 MB).FramePrefixSizePrefix size: 4 bytes (LE length) + 1 byte (frame type) = 5 bytes.
