acceptsStrategy()

in common/lib/plugin_manager.ts [277:306]


  acceptsStrategy(role: HostRole, strategy: string) {
    let chain: Set<ConnectionPlugin> = PluginManager.STRATEGY_PLUGIN_CHAIN_CACHE.get(this._plugins);
    if (!chain) {
      chain = new Set();
      let acceptsStrategy: boolean = false;

      for (const plugin of this._plugins) {
        if (
          plugin.getSubscribedMethods().has(PluginManager.ALL_METHODS) ||
          plugin.getSubscribedMethods().has(PluginManager.ACCEPTS_STRATEGY_METHOD)
        ) {
          chain.add(plugin);
          if (!acceptsStrategy && plugin.acceptsStrategy(role, strategy)) {
            acceptsStrategy = true;
          }
        }
      }

      PluginManager.STRATEGY_PLUGIN_CHAIN_CACHE.set(this._plugins, chain);
      return acceptsStrategy;
    } else {
      for (const plugin of chain) {
        if (plugin.acceptsStrategy(role, strategy)) {
          return true;
        }
      }
    }

    return false;
  }