unsubscribeAllFor method

Future<void> unsubscribeAllFor({
  1. required Client client,
  2. required MCPUIRuntime runtime,
  3. required String ownerKey,
})

Unsubscribes every resource associated with ownerKey. Used by the orchestrator's closeApp path to prevent leaked subscriptions.

Implementation

Future<void> unsubscribeAllFor({
  required Client client,
  required MCPUIRuntime runtime,
  required String ownerKey,
}) async {
  final uris = _active[ownerKey];
  if (uris == null || uris.isEmpty) return;
  for (final uri in List<String>.from(uris)) {
    try {
      await unsubscribe(
        client: client,
        runtime: runtime,
        uri: uri,
        ownerKey: ownerKey,
      );
    } catch (e) {
      _logger.warn(
          'unsubscribeAllFor: unsubscribe failed',
          {
            'uri': uri,
            'ownerKey': ownerKey,
          },
          e);
    }
  }
}