disconnect method

  1. @override
Future<void> disconnect({
  1. required String topic,
})
override

Implementation

@override
Future<void> disconnect({required String topic}) async {
  _checkInitialized();

  core.logger.i('[$runtimeType] disconnect $topic');

  await _isValidDisconnect(topic);
  if (pairings.has(topic)) {
    // Send the request to delete the pairing, we don't care if it fails
    try {
      sendRequest(
        topic,
        MethodConstants.WC_PAIRING_DELETE,
        Errors.getSdkError(Errors.USER_DISCONNECTED).toJson(),
      );
    } catch (_) {}

    // Delete the pairing
    await pairings.delete(topic);

    onPairingDelete.broadcast(
      PairingEvent(
        topic: topic,
      ),
    );
  }
}