matchesFeature method

  1. @override
bool matchesFeature(
  1. List<XMLNode> features
)
override

Returns true if a feature in features, which are the children of the <stream:features /> nonza, can be negotiated. Otherwise, returns false.

Implementation

@override
bool matchesFeature(List<XMLNode> features) {
  // Is SASL advertised?
  final mechanisms = features.firstWhereOrNull(
    (XMLNode feature) => feature.attributes['xmlns'] == saslXmlns,
  );
  if (mechanisms == null) return false;

  // Is SASL PLAIN advertised?
  return mechanisms.children.firstWhereOrNull(
        (XMLNode mechanism) => mechanism.text == mechanismName,
      ) !=
      null;
}