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 (this.transport != null && this.clientOrDeviceHandle != null) {
    try {
      int? hndl = handle ?? this.clientOrDeviceHandle;
      await this.transport?.close(hndl);
      this.rootCapture = null;
      this.transport = null;
      this.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');
  }
}