Documentation
    Preparing search index...

    Class ConnectionManager

    Implements

    Index

    Constructors

    Methods

    • Connects to a peer using specific protocol codecs. This is a direct proxy to libp2p's dialProtocol method.

      Parameters

      • peer: PeerId | MultiaddrInput

        The peer to connect to (PeerId or multiaddr)

      • protocolCodecs: string[]

        Array of protocol codec strings to establish

      Returns Promise<Stream>

      Promise resolving to a Stream connection to the peer

      Error if the connection cannot be established

      const stream = await connectionManager.dial(
      peerId,
      ["/vac/waku/store/2.0.0-beta4"]
      );
    • Retrieves a list of currently connected peers, optionally filtered by protocol codec. Results are sorted by ping time (lowest first).

      Parameters

      • Optionalcodec: string

        Optional protocol codec to filter peers by

      Returns Promise<Peer[]>

      Promise resolving to an array of connected Peer objects

      // Get all connected peers
      const allPeers = await connectionManager.getConnectedPeers();

      // Get peers supporting a specific protocol
      const storePeers = await connectionManager.getConnectedPeers(
      "/vac/waku/store/2.0.0-beta4"
      );
    • Terminates the connection to a specific peer.

      Parameters

      • peer: PeerId | MultiaddrInput

        The peer to disconnect from (PeerId or multiaddr)

      Returns Promise<boolean>

      Promise resolving to true if disconnection was successful, false otherwise

      const success = await connectionManager.hangUp(peerId);
      if (success) {
      console.log("Peer disconnected successfully");
      }