canInlineFeature method

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

Called by the SASL2 negotiator to find out whether the negotiator is willing to inline a feature. features is the list of elements inside the element.

Implementation

@override
bool canInlineFeature(List<XMLNode> features) {
  final sm = attributes.getManagerById<StreamManagementManager>(smManager)!;

  // We do not check here for authentication as enabling/resuming happens inline
  // with the authentication.
  if (sm.state.streamResumptionId != null && !_resumeFailed) {
    // We can try to resume the stream or enable the stream
    return features.firstWhereOrNull(
          (child) => child.xmlns == smXmlns,
        ) !=
        null;
  } else {
    // We can try to enable SM
    return features.firstWhereOrNull(
          (child) => child.tag == 'enable' && child.xmlns == smXmlns,
        ) !=
        null;
  }
}