connect method

  1. @override
Future<BleLink> connect(
  1. String token, {
  2. Duration? timeout,
})
override

Opens a link, as central, to the device that advertises token.

Implementation

@override
Future<BleLink> connect(String token, {Duration? timeout}) async {
  final remote = _find(token);
  await Future<void>.delayed(_network.latency);
  final central = _FakeLink(this, isCentral: true, remoteId: remote._id);
  final peripheral = _FakeLink(remote, isCentral: false, remoteId: _id);
  central._peer = peripheral;
  peripheral._peer = central;
  _links.add(central);
  remote._links.add(peripheral);
  remote._incoming.add(peripheral);
  return central;
}