unsubscribe method
FR-RES-004
Implementation
Future<void> unsubscribe({
required Client client,
required MCPUIRuntime runtime,
required String uri,
String? ownerKey,
}) async {
_logger.debug('Unsubscribing resource', {'uri': uri});
try {
await client.unsubscribeResource(uri);
} catch (e, st) {
_logger.logError('unsubscribeResource failed', e, st, {'uri': uri});
throw ResourceSubscriptionException(uri, cause: e);
}
runtime.unregisterResourceSubscription(uri);
if (ownerKey != null) {
_active[ownerKey]?.remove(uri);
if (_active[ownerKey]?.isEmpty ?? false) {
_active.remove(ownerKey);
}
}
}