create static method

Future<RelayManager> create(
  1. Host host, {
  2. int maxReservations = 128,
  3. int maxConnections = 128,
  4. int reservationTtl = 3600,
  5. int connectionDuration = 3600,
  6. int connectionData = 1 << 20,
})

Creates and initializes a new RelayManager.

The manager will listen for reachability changes and start/stop the underlying Circuit Relay v2 service accordingly.

host is the libp2p host instance. Optional parameters maxReservations, maxConnections, reservationTtl, connectionDuration, and connectionData are used to configure the Resources for the managed relay service.

Implementation

static Future<RelayManager> create(
  Host host, {
  int maxReservations = 128,
  int maxConnections = 128,
  int reservationTtl = 3600, // seconds
  int connectionDuration = 3600, // seconds
  int connectionData = 1 << 20, // 1 MiB
}) async {
  final relayResources = Resources(
    maxReservations: maxReservations,
    maxConnections: maxConnections,
    reservationTtl: reservationTtl,
    connectionDuration: connectionDuration,
    connectionData: connectionData,
  );

  final manager = RelayManager._(host, relayResources);
  manager._backgroundCompleter = Completer<void>();
  manager._startBackgroundListener();
  _log.fine('RelayManager created and service monitoring started.');
  return manager;
}