close method

Future<int> close([
  1. int? handle
])

close capture connection. Remove any handles and reset root transport and capture.

Implementation

Future<int> close([int? handle]) async {
  if (transport != null && clientOrDeviceHandle != null) {
    try {
      final int hndl = handle ?? clientOrDeviceHandle ?? 0;
      await transport?.close(hndl);
      rootCapture = null;
      transport = null;
      clientOrDeviceHandle = null;
      return SktErrors.ESKT_NOERROR;
    } on CaptureException {
      rethrow;
    } catch (e) {
      throw CaptureException(-32602, 'Something went wrong.', e.toString());
    }
  } else {
    throw CaptureException(
        SktErrors.ESKT_NOTINITIALIZED, 'Transport is not initialized');
  }
}