discoverClients method

Future<List<DiscoveredClient>> discoverClients({
  1. Duration timeout = const Duration(seconds: 5),
})

Implementation

Future<List<DiscoveredClient>> discoverClients(
    {Duration timeout = const Duration(seconds: 5)}) async {
  final list = <DiscoveredClient>[];

  final sub = clients.listen((client) => list.add(client));

  if (_sockets.isEmpty) {
    await start(port: 0);
  }

  search();
  await Future.delayed(timeout);
  await sub.cancel();
  stop();
  return list;
}