@chainsafe/libp2p-yamux
    Preparing search index...

    Class YamuxStream

    YamuxStream is used to represent a logical stream within a session

    Hierarchy

    Index

    Constructors

    Properties

    direction: Direction

    Outbound streams are opened by the local node, inbound streams are opened by the remote

    id: string

    Unique identifier for a stream. Identifiers are not unique across muxers.

    log: Logger

    The stream logger

    metadata: Record<string, unknown>

    User defined stream metadata

    name?: string
    protocol?: string

    The protocol negotiated for this stream

    readStatus: ReadStatus

    The current status of the readable end of the stream

    source: AsyncGenerator<Uint8ArrayList, void, unknown>
    status: StreamStatus

    The current status of the stream

    timeline: StreamTimeline

    Lifecycle times for the stream

    writeStatus: WriteStatus

    The current status of the writable end of the stream

    Methods

    • Parameters

      Returns void

    • Parameters

      Returns void

    • Parameters

      Returns void

    • Close immediately for reading and writing and send a reset message (local error)

      Parameters

      Returns void

    • Closes the stream for reading and writing.

      Any buffered data in the source can still be consumed and the stream will end normally.

      This will cause a CLOSE message to be sent to the remote, unless the sink has already ended.

      The sink and the source will return normally.

      Parameters

      Returns Promise<void>

    • Closes the stream for reading. If iterating over the source of this stream in a for await of loop, it will return (exit the loop) after any buffered data has been consumed.

      This function is called automatically by the muxer when it receives a CLOSE message from the remote.

      The source will return normally, the sink will continue to consume.

      Parameters

      Returns Promise<void>

    • Closes the stream for writing. If iterating over the source of this stream in a for await of loop, it will return (exit the loop) after any buffered data has been consumed.

      The source will return normally, the sink will continue to consume.

      Parameters

      Returns Promise<void>

    • The underlying muxer has closed, no more messages can be sent or will be received, close immediately to free up resources

      Returns void

    • Parameters

      Returns void

    • Parameters

      Returns void

    • The remote closed for reading so we should not send any more messages

      Returns void

    • The remote closed for writing so we should expect to receive no more messages

      Returns void

    • Receive a reset message - close immediately for reading and writing (remote error)

      Returns void

    • Send a message to the remote muxer, informing them no more data messages will be read by this end of the stream

      Returns Promise<void>

    • Send a message to the remote muxer, informing them no more data messages will be sent by this end of the stream

      Returns Promise<void>

    • Send a message to the remote muxer informing them a new stream is being opened.

      This is a noop for Yamux because the first window update is sent when .newStream is called on the muxer which opens the stream on the remote.

      Returns Promise<void>

    • potentially sends a window update enabling further writes to take place.

      Returns void

    • When an extending class reads data from it's implementation-specific source, call this method to allow the stream consumer to read the data.

      Parameters

      Returns void

    • Returns the amount of unread data - can be used to prevent large amounts of data building up when the stream consumer is too slow.

      Returns number