disconnect method

  1. @override
Future<void> disconnect()
override

Implementation

@override
Future<void> disconnect() async {
  final completer = Completer<void>();

  try {
    await Future.any([
      sendRequest({'method': 'disconnect', 'params': []}),
      Future.delayed(const Duration(seconds: disconnectTimeout)),
    ]);
  } catch (e) {
    logger.e('Provider disconnect', e);
  } finally {
    if (!completer.isCompleted) {
      await _removeSession();
      completer.complete();
    }
  }

  return completer.future;
}