start method

Future<void> start(
  1. Uint8List peerId,
  2. int port
)

Implementation

Future<void> start(Uint8List peerId, int port) async {
  if ((await Connectivity().checkConnectivity()).contains(
    ConnectivityResult.wifi,
  )) {
    try {
      _registration ??= await register(
        Service(
          name: serviceName,
          type: serviceType,
          port: port,
          txt: {
            _txtPeerId: _utf8Encoder.convert(base64Encode(peerId)),
          },
        ),
      ).timeout(timeout);
    } on Object catch (e) {
      if (kDebugMode) print(e);
    }
    try {
      _discovery ??=
          await startDiscovery(
              serviceType,
              ipLookupType: IpLookupType.any,
            ).timeout(timeout)
            ..addServiceListener(_onServiceFound);
    } on Object catch (e) {
      if (kDebugMode) print(e);
    }
  }
}