transportHelper method

Future<int?> transportHelper(
  1. AppInfo appInfo,
  2. Function eventNotification, [
  3. CaptureOptions? options
])

Initialize transport for capture.

Implementation

Future<int?> transportHelper(AppInfo appInfo, Function eventNotification,
    [CaptureOptions? options]) async {
  if (options != null) {
    this.transport =
        options.transport ?? Transport().getTransport(this.logger);
    this.host = options.host ?? defaultHost;
  } else {
    this.transport = Transport().getTransport(this.logger);
  }

  try {
    int? _tryOpen = await this.transport!.openClient(host, appInfo,
        (dynamic event, int handle) {
      return eventNotification(event, handle);
    });
    this.clientOrDeviceHandle = _tryOpen;
    return this.clientOrDeviceHandle;
  } on CaptureException {
    rethrow;
  } catch (e) {
    throw CaptureException(SktErrors.ESKT_COMMUNICATIONERROR, 'There was an error during communication.', e.toString());
  }
}