# registerManagers method

Future <void> registerManagers(

1. List <XmppManagerBase> managers

)

Registers a list of XmppManagerBase sub-classes as managers on this connection.

## Implementation

    Future<void> registerManagers(List<XmppManagerBase> managers) async {
      for (final manager in managers) {
        _log.finest('Registering ${manager.id}');
        manager.register(
          XmppManagerAttributes(
            sendStanza: sendStanza,
            sendNonza: sendRawXML,
            sendEvent: _sendEvent,
            getConnectionSettings: () => connectionSettings,
            getManagerById: getManagerById,
            getFullJID: _getJidWithResource,
            getSocket: () => _socket,
            getConnection: () => this,
            getNegotiatorById: _negotiationsHandler.getNegotiatorById,
          ),
        );

        _xmppManagers[manager.id] = manager;

        _incomingStanzaHandlers.addAll(
          manager.getIncomingStanzaHandlers().map((h) => (h, manager.name)),
        );
        _incomingPreStanzaHandlers.addAll(
          manager.getIncomingPreStanzaHandlers().map((h) => (h, manager.name)),
        );
        _outgoingPreStanzaHandlers.addAll(
          manager.getOutgoingPreStanzaHandlers().map((h) => (h, manager.name)),
        );
        _outgoingPostStanzaHandlers.addAll(
          manager.getOutgoingPostStanzaHandlers().map((h) => (h, manager.name)),
        );
      }

      // Sort them
      _incomingStanzaHandlers.sort(_stanzaHandlerWrapperSortComparator);
      _incomingPreStanzaHandlers.sort(_stanzaHandlerWrapperSortComparator);
      _outgoingPreStanzaHandlers.sort(_stanzaHandlerWrapperSortComparator);
      _outgoingPostStanzaHandlers.sort(_stanzaHandlerWrapperSortComparator);

      // Run the post register callbacks
      for (final manager in _xmppManagers.values) {
        if (!manager.initialized) {
          _log.finest('Running post-registration callback for ${manager.name}');
          await manager.postRegisterCallback();
        }
      }
    }