Home

Awesome

ssb-conn-hub

Module that manages active connections to peers. For use with the SSB CONN family of modules.

Visual metaphor: a network switch managing connections to other peers, capable of starting or stopping connections.

hub.png

Usage

Prerequisites:

This module is only used to create an SSB CONN plugin, not used directly by applications. A ConnHub instance should be available on the CONN plugin, with the following API:

API

Recipes

How can I get the RPC object for the remote peer connected with me?

Assuming you're access ConnHub from ssb-conn, listen to connection events on ConnHub, filter for 'connected' events, and they should contain the RPC object on the event's details field:

pull(
  ssb.conn.hub().listen(),
  pull.filter(event => event.type === 'connected'),
  pull.drain(event => {
    const rpc = event.details.rpc
    // `rpc` object has public methods such as `rpc.createHistoryStream()`
  })
)

License

MIT