libp2p
    Preparing search index...

    Interface MultiaddrConnection

    A MultiaddrConnection is returned by a transport after dialing a peer. It is a low-level primitive and is the raw connection, typically without encryption or stream multiplexing.

    interface MultiaddrConnection {
        direction: MessageStreamDirection;
        inactivityTimeout: number;
        log: Logger;
        maxReadBufferLength: number;
        maxWriteBufferLength?: number;
        readBufferLength: number;
        remoteAddr: Multiaddr;
        status: MessageStreamStatus;
        timeline: MultiaddrConnectionTimeline;
        writableNeedsDrain: boolean;
        writeBufferLength: number;
        "[asyncIterator]"(): AsyncIterator<
            Uint8Array<ArrayBufferLike>
            | Uint8ArrayList,
            any,
            any,
        >;
        abort(err: Error): void;
        addEventListener<K extends keyof MessageStreamEvents>(
            type: K,
            listener: EventHandler<MessageStreamEvents[K]> | null,
            options?: boolean | AddEventListenerOptions,
        ): void;
        close(options?: AbortOptions): Promise<void>;
        dispatchEvent(event: Event): boolean;
        dispatchEvent(event: Event): boolean;
        listenerCount(type: string): number;
        onDrain(options?: AbortOptions): Promise<void>;
        pause(): void;
        push(buf: Uint8Array<ArrayBufferLike> | Uint8ArrayList): void;
        removeEventListener<K extends keyof MessageStreamEvents>(
            type: K,
            listener?: EventHandler<MessageStreamEvents[K]> | null,
            options?: boolean | EventListenerOptions,
        ): void;
        removeEventListener(
            type: string,
            listener?: EventHandler<Event>,
            options?: boolean | EventListenerOptions,
        ): void;
        resume(): void;
        safeDispatchEvent<Detail>(
            type: keyof MessageStreamEvents,
            detail?: CustomEventInit<Detail>,
        ): boolean;
        send(data: Uint8Array<ArrayBufferLike> | Uint8ArrayList): boolean;
        unshift(data: Uint8Array<ArrayBufferLike> | Uint8ArrayList): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    Whether this stream is inbound or outbound

    inactivityTimeout: number

    If no data is transmitted over the stream in this many ms, the stream will be aborted with an InactivityTimeoutError

    log: Logger

    A logging implementation that can be used to log stream-specific messages

    maxReadBufferLength: number

    The maximum number of bytes to store when paused. If receipt of more bytes from the remote end of the stream causes the buffer size to exceed this value the stream will be reset and a 'close' event emitted.

    This value can be changed at runtime.

    maxWriteBufferLength?: number

    When the .send method returns false it means that the underlying resource has signalled that it's write buffer is full. If the user continues to call .send, outgoing bytes are stored in an internal buffer until the underlying resource signals that it can accept more data.

    If the size of that internal buffer exceed this value the stream will be reset and a 'close' event emitted.

    This value can be changed at runtime.

    readBufferLength: number

    Returns the number of bytes that are queued to be read

    remoteAddr: Multiaddr

    The address of the remote end of the connection

    The current status of the message stream

    When stream life cycle events occurred

    writableNeedsDrain: boolean

    If this property is true, the underlying transport has signalled that its write buffer is full and that .send should not be called again.

    A drain event will be emitted after which is its safe to call .send again to resume sending.

    writeBufferLength: number

    Returns the number of bytes that are queued to be written

    Methods

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      Returns boolean

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      Returns boolean

    • Parameters

      • type: string

      Returns number

    • Stop emitting further 'message' events. Any received data will be stored in an internal buffer. If the buffer size reaches maxReadBufferLength, the stream will be reset and a StreamAbortEvent emitted.

      If the underlying resource supports it, the remote peer will be instructed to pause transmission of further data.

      Returns void

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Type Parameters

      Parameters

      Returns void

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • Optionallistener: EventHandler<Event>
      • Optionaloptions: boolean | EventListenerOptions

      Returns void