An implementation of the js-libp2p connection. Any libp2p transport should use an upgrader to return this connection.

Hierarchy

  • Connection

Index

References

ConectionStat

Re-exports ConectionStat

ConnectionOptions

Re-exports ConnectionOptions

MuxedStream

Re-exports MuxedStream

Status

Re-exports Status

StreamData

Re-exports StreamData

Timeline

Re-exports Timeline

Constructors

constructor

  • An implementation of the js-libp2p connection. Any libp2p transport should use an upgrader to return this connection.

    Parameters

    Returns Connection

Properties

_close

_close: () => Promise<void>

Reference to the close function of the raw connection

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

_closing

_closing: void | undefined

_getStreams

_getStreams: () => MuxedStream[]

Reference to the getStreams function of the muxer

Type declaration

_newStream

_newStream: (protocols: string | string[]) => Promise<{ protocol: string; stream: MuxedStream }>

Reference to the new stream function of the multiplexer

Type declaration

    • (protocols: string | string[]): Promise<{ protocol: string; stream: MuxedStream }>
    • Parameters

      • protocols: string | string[]

      Returns Promise<{ protocol: string; stream: MuxedStream }>

_stat

_stat: ConectionStat & { status: Status }

Connection metadata.

id

id: string

Connection identifier.

localAddr

localAddr: Multiaddr | undefined

Observed multiaddr of the local peer

localPeer

localPeer: PeerId

Local peer id.

registry

registry: Map<any, any>

Connection streams registry

remoteAddr

remoteAddr: Multiaddr

Observed multiaddr of the remote peer

remotePeer

remotePeer: PeerId

Remote peer id.

tags

tags: string[]

User provided tags

Accessors

[Symbol.toStringTag]

  • get [Symbol.toStringTag](): string
  • Returns string

stat

streams

  • Get all the streams of the muxer.

    Returns MuxedStream[]

Methods

addStream

  • addStream(muxedStream: MuxedStream, __namedParameters: { metadata: any; protocol: string }): void
  • Add a stream when it is opened to the registry.

    Parameters

    • muxedStream: MuxedStream

      a muxed stream

    • __namedParameters: { metadata: any; protocol: string }
      • metadata: any
      • protocol: string

    Returns void

close

  • close(): Promise<void>
  • Close the connection.

    Returns Promise<void>

newStream

  • newStream(protocols: string | string[]): Promise<{ protocol: string; stream: MuxedStream }>
  • Create a new stream from this connection

    Parameters

    • protocols: string | string[]

      intended protocol for the stream

    Returns Promise<{ protocol: string; stream: MuxedStream }>

    } with muxed+multistream-selected stream and selected protocol

removeStream

  • removeStream(id: string): void
  • Remove stream registry after it is closed.

    Parameters

    • id: string

      identifier of the stream

    Returns void

Static isConnection

  • isConnection(other: any): other is Connection
  • Checks if the given value is a Connection instance.

    Parameters

    • other: any

    Returns other is Connection