Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinaryMessagePipe

A BinaryMessagePipe is capable of sending and retrieving binary messages i.e. {@link Uint8Array}s 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.

Hierarchy

  • BinaryMessagePipe

Implements

Index

Constructors

Properties

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

Accessors

  • get messageStartByteLength(): number
  • get onMessage(): Event<Uint8Array>

Methods

  • dataHandler(chunk: Uint8Array): void
  • dispose(): void
  • emitCachedMessage(): void
  • encodeMessageStart(message: Uint8Array): Uint8Array
  • Encodes the start of a new message into a {@link 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

  • handleChunk(chunk: Uint8Array): void
  • handleMessageContentChunk(chunk: Uint8Array): void
  • handleNewMessage(chunk: Uint8Array): void
  • readMessageStart(chunk: Uint8Array): number
  • 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.

    throws

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

    Parameters

    • chunk: Uint8Array

      The stream chunk.

    Returns number

    The length of the message content to read.

  • send(message: Uint8Array): void