disconnectSession method

  1. @override
Future<void> disconnectSession({
  1. required String topic,
  2. required WalletConnectError reason,
})
override

Implementation

@override
Future<void> disconnectSession({
  required String topic,
  required WalletConnectError reason,
}) async {
  _checkInitialized();
  await _isValidDisconnect(topic);

  if (sessions.has(topic)) {
    // Send the request to delete the session, we don't care if it fails
    try {
      core.pairing.sendRequest(
        topic,
        MethodConstants.WC_SESSION_DELETE,
        WcSessionDeleteRequest(
          code: reason.code,
          message: reason.message,
          data: reason.data,
        ),
      );
    } catch (_) {}

    await _deleteSession(topic);
  } else {
    await core.pairing.disconnect(topic: topic);
  }
}