Search Results for

    Show / Hide Table of Contents

    Class Framing

    TBD

    Inheritance
    object
    Framing
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Streams.Dsl
    Assembly: Akka.Streams.dll
    Syntax
    public static class Framing

    Methods

    | Edit this page View Source

    Delimiter(ByteString, int, bool)

    Creates a Flow that handles decoding a stream of unstructured byte chunks into a stream of frames where the incoming chunk stream uses a specific byte-sequence to mark frame boundaries.

    The decoded frames will not include the separator sequence.

    If there are buffered bytes (an incomplete frame) when the input stream finishes and allowTruncation is set to false then this Flow will fail the stream reporting a truncated frame.

    Declaration
    public static Flow<ByteString, ByteString, NotUsed> Delimiter(ByteString delimiter, int maximumFrameLength, bool allowTruncation = false)
    Parameters
    Type Name Description
    ByteString delimiter

    The byte sequence to be treated as the end of the frame.

    int maximumFrameLength

    The maximum length of allowed frames while decoding. If the maximum length is exceeded this Flow will fail the stream.

    bool allowTruncation

    If false, then when the last frame being decoded contains no valid delimiter this Flow fails the stream instead of returning a truncated frame.

    Returns
    Type Description
    Flow<ByteString, ByteString, NotUsed>

    TBD

    | Edit this page View Source

    LengthField(int, int, int, ByteOrder)

    Creates a Flow that decodes an incoming stream of unstructured byte chunks into a stream of frames, assuming that incoming frames have a field that encodes their length.

    If the input stream finishes before the last frame has been fully decoded, this Flow will fail the stream reporting a truncated frame.

    Declaration
    public static Flow<ByteString, ByteString, NotUsed> LengthField(int fieldLength, int maximumFramelength, int fieldOffset = 0, ByteOrder byteOrder = ByteOrder.LittleEndian)
    Parameters
    Type Name Description
    int fieldLength

    The length of the "Count" field in bytes

    int maximumFramelength

    The maximum length of allowed frames while decoding. If the maximum length is exceeded this Flow will fail the stream. This length includes the header (i.e the offset and the length of the size field)

    int fieldOffset

    The offset of the field from the beginning of the frame in bytes

    ByteOrder byteOrder

    The ByteOrder to be used when decoding the field

    Returns
    Type Description
    Flow<ByteString, ByteString, NotUsed>

    TBD

    Exceptions
    Type Condition
    ArgumentException

    This exception is thrown when the specified fieldLength is not equal to either 1, 2, 3 or 4.

    | Edit this page View Source

    LengthField(int, int, int, ByteOrder, Func<IReadOnlyList<byte>, int, int>)

    Creates a Flow that decodes an incoming stream of unstructured byte chunks into a stream of frames, assuming that incoming frames have a field that encodes their length.

    If the input stream finishes before the last frame has been fully decoded, this Flow will fail the stream reporting a truncated frame.

    Declaration
    public static Flow<ByteString, ByteString, NotUsed> LengthField(int fieldLength, int fieldOffset, int maximumFrameLength, ByteOrder byteOrder, Func<IReadOnlyList<byte>, int, int> computeFrameSize)
    Parameters
    Type Name Description
    int fieldLength

    The length of the "Count" field in bytes

    int fieldOffset

    The offset of the field from the beginning of the frame in bytes.

    int maximumFrameLength

    The maximum length of allowed frames while decoding. If the maximum length is exceeded this Flow will fail the stream. This length includes the header (i.e the offset and the length of the size field)

    ByteOrder byteOrder

    The ByteOrder to be used when decoding the field.

    Func<IReadOnlyList<byte>, int, int> computeFrameSize

    This function can be supplied if frame size is varied or needs to be computed in a special fashion. For example, frame can have a shape like this: [offset bytes][body size bytes][body bytes][footer bytes]. Then computeFrameSize can be used to compute the frame size: (offset bytes, computed size) => (actual frame size). "Actual frame size" must be equal or bigger than sum of fieldOffset and fieldLength, the operator fails otherwise.

    Returns
    Type Description
    Flow<ByteString, ByteString, NotUsed>

    TBD

    Exceptions
    Type Condition
    ArgumentException

    This exception is thrown when the specified fieldLength is not equal to either 1, 2, 3 or 4.

    | Edit this page View Source

    SimpleFramingProtocol(int)

    Returns a BidiFlow that implements a simple framing protocol. This is a convenience wrapper over LengthField(int, int, int, ByteOrder) and simply attaches a length field header of four bytes (using big endian encoding) to outgoing messages, and decodes such messages in the inbound direction. The decoded messages do not contain the header.

    This BidiFlow is useful if a simple message framing protocol is needed (for example when TCP is used to send individual messages) but no compatibility with existing protocols is necessary.

    The encoded frames have the layout {{{ [4 bytes length field, Big Endian][User Payload] }}} The length field encodes the length of the user payload excluding the header itself.

    Declaration
    public static BidiFlow<ByteString, ByteString, ByteString, ByteString, NotUsed> SimpleFramingProtocol(int maximumMessageLength)
    Parameters
    Type Name Description
    int maximumMessageLength

    Maximum length of allowed messages. If sent or received messages exceed the configured limit this BidiFlow will fail the stream. The header attached by this BidiFlow are not included in this limit.

    Returns
    Type Description
    BidiFlow<ByteString, ByteString, ByteString, ByteString, NotUsed>

    TBD

    | Edit this page View Source

    SimpleFramingProtocolDecoder(int)

    Protocol decoder that is used by SimpleFramingProtocol(int)

    Declaration
    public static Flow<ByteString, ByteString, NotUsed> SimpleFramingProtocolDecoder(int maximumMessageLength)
    Parameters
    Type Name Description
    int maximumMessageLength

    TBD

    Returns
    Type Description
    Flow<ByteString, ByteString, NotUsed>

    TBD

    | Edit this page View Source

    SimpleFramingProtocolEncoder(int)

    Protocol encoder that is used by SimpleFramingProtocol(int)

    Declaration
    public static Flow<ByteString, ByteString, NotUsed> SimpleFramingProtocolEncoder(int maximumMessageLength)
    Parameters
    Type Name Description
    int maximumMessageLength

    TBD

    Returns
    Type Description
    Flow<ByteString, ByteString, NotUsed>

    TBD

    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET