Class BinaryMessagePipe

A BinaryMessagePipe is capable of sending and retrieving binary messages i.e. Uint8Arrays over and underlying streamed process pipe/fd. The message length of individual messages is encoding at the beginning of a new message. This makes it possible to extract messages from the streamed data.

Implements

Constructors

Properties

cachedMessageData: StreamedMessageData = ...
onMessageEmitter: Emitter<Uint8Array> = ...
underlyingPipe: Duplex
MESSAGE_START_IDENTIFIER: "<MessageStart>" = '<MessageStart>'

Accessors

Methods

  • Encodes the start of a new message into a Uint8Array. The message start consists of a identifier string and the length of the following message.

    Parameters

    • message: Uint8Array

    Returns Uint8Array

    the buffer contains the encoded message start

  • Reads the start of a new message from a stream chunk (or cached message) received from the underlying pipe. The message start is expected to consist of an identifier string and the length of the message.

    Parameters

    • chunk: Uint8Array

      The stream chunk.

    Returns number

    The length of the message content to read.

    Throws

    An error if the message start can not be read successfully.