disconnectSession method
Future<void>
disconnectSession({
- required String topic,
- required WalletConnectError reason,
override
Implementation
@override
Future<void> disconnectSession({
required String topic,
required WalletConnectError reason,
}) async {
_checkInitialized();
try {
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);
}
} on WalletConnectError catch (error, s) {
core.logger.e(
'[$runtimeType] disconnectSession()',
error: error,
stackTrace: s,
);
}
}