Interface MessageReader

Reads JSON-RPC messages from some underlying transport.

interface MessageReader {
    onClose: Event<void>;
    onError: Event<Error>;
    onPartialMessage: Event<PartialMessageInfo>;
    dispose(): void;
    listen(callback: DataCallback): Disposable;
}

Implemented by

Properties

onClose: Event<void>

An event raised when the end of the underlying transport has been reached.

onError: Event<Error>

Raised whenever an error occurs while reading a message.

onPartialMessage: Event<PartialMessageInfo>

An event that may be raised to inform the owner that only part of a message has been received. A MessageReader implementation may choose to raise this event after a timeout elapses while waiting for more of a partially received message to be received.

Methods

  • Releases resources incurred from reading or raising events. Does NOT close the underlying transport, if any.

    Returns void

  • Begins listening for incoming messages. To be called at most once.

    Parameters

    • callback: DataCallback

      A callback for receiving decoded messages.

    Returns Disposable