directConnect method

  1. @override
Future<void> directConnect(
  1. PeerId peerId
)
override

DirectConnect attempts to make a direct connection with a remote peer. It first attempts a direct dial (if we have a public address of that peer), and then coordinates a hole punch over the given relay connection.

Implementation

@override
Future<void> directConnect(PeerId peerId) async {
  await _hasPublicAddrsChan.future;

  final holePuncher = await _holePuncherMutex.synchronized(() => _holePuncher);
  if (holePuncher == null) {
    throw Exception('Holepunch service not initialized');
  }

  return holePuncher.directConnect(peerId);
}