Compare commits

...

2 Commits

4 changed files with 12 additions and 10 deletions

View File

@ -21,23 +21,28 @@ abstract class XmppManagerBase {
} }
/// Return the StanzaHandlers associated with this manager that deal with stanzas we /// Return the StanzaHandlers associated with this manager that deal with stanzas we
/// send. These are run before the stanza is sent. /// send. These are run before the stanza is sent. The higher the value of the
/// handler's priority, the earlier it is run.
List<StanzaHandler> getOutgoingPreStanzaHandlers() => []; List<StanzaHandler> getOutgoingPreStanzaHandlers() => [];
/// Return the StanzaHandlers associated with this manager that deal with stanzas we /// Return the StanzaHandlers associated with this manager that deal with stanzas we
/// send. These are run after the stanza is sent. /// send. These are run after the stanza is sent. The higher the value of the
/// handler's priority, the earlier it is run.
List<StanzaHandler> getOutgoingPostStanzaHandlers() => []; List<StanzaHandler> getOutgoingPostStanzaHandlers() => [];
/// Return the StanzaHandlers associated with this manager that deal with stanzas we /// Return the StanzaHandlers associated with this manager that deal with stanzas we
/// receive. /// receive. The higher the value of the
/// handler's priority, the earlier it is run.
List<StanzaHandler> getIncomingStanzaHandlers() => []; List<StanzaHandler> getIncomingStanzaHandlers() => [];
/// Return the StanzaHandlers associated with this manager that deal with stanza handlers /// Return the StanzaHandlers associated with this manager that deal with stanza handlers
/// that have to run before the main ones run. This is useful, for example, for OMEMO /// that have to run before the main ones run. This is useful, for example, for OMEMO
/// as we have to decrypt the stanza before we do anything else. /// as we have to decrypt the stanza before we do anything else. The higher the value
/// of the handler's priority, the earlier it is run.
List<StanzaHandler> getIncomingPreStanzaHandlers() => []; List<StanzaHandler> getIncomingPreStanzaHandlers() => [];
/// Return the NonzaHandlers associated with this manager. /// Return the NonzaHandlers associated with this manager. The higher the value of the
/// handler's priority, the earlier it is run.
List<NonzaHandler> getNonzaHandlers() => []; List<NonzaHandler> getNonzaHandlers() => [];
/// Return a list of features that should be included in a disco response. /// Return a list of features that should be included in a disco response.

View File

@ -5,7 +5,6 @@ import 'package:moxxmpp/src/stanza.dart';
import 'package:moxxmpp/src/stringxml.dart'; import 'package:moxxmpp/src/stringxml.dart';
abstract class Handler { abstract class Handler {
const Handler(this.matchStanzas, { this.nonzaTag, this.nonzaXmlns }); const Handler(this.matchStanzas, { this.nonzaTag, this.nonzaXmlns });
final String? nonzaTag; final String? nonzaTag;
final String? nonzaXmlns; final String? nonzaXmlns;
@ -32,7 +31,6 @@ abstract class Handler {
} }
class NonzaHandler extends Handler { class NonzaHandler extends Handler {
NonzaHandler({ NonzaHandler({
required this.callback, required this.callback,
String? nonzaTag, String? nonzaTag,
@ -46,7 +44,6 @@ class NonzaHandler extends Handler {
} }
class StanzaHandler extends Handler { class StanzaHandler extends Handler {
StanzaHandler({ StanzaHandler({
required this.callback, required this.callback,
this.tagXmlns, this.tagXmlns,

View File

@ -142,7 +142,7 @@ class StreamManagementManager extends XmppManagerBase {
]; ];
@override @override
List<StanzaHandler> getIncomingStanzaHandlers() => [ List<StanzaHandler> getIncomingPreStanzaHandlers() => [
StanzaHandler( StanzaHandler(
callback: _onServerStanzaReceived, callback: _onServerStanzaReceived,
priority: 9999, priority: 9999,

View File

@ -4,7 +4,7 @@ import '../helpers/logging.dart';
import '../helpers/xmpp.dart'; import '../helpers/xmpp.dart';
Future<void> runIncomingStanzaHandlers(StreamManagementManager man, Stanza stanza) async { Future<void> runIncomingStanzaHandlers(StreamManagementManager man, Stanza stanza) async {
for (final handler in man.getIncomingStanzaHandlers()) { for (final handler in man.getIncomingPreStanzaHandlers()) {
if (handler.matches(stanza)) await handler.callback(stanza, StanzaHandlerData(false, false, null, stanza)); if (handler.matches(stanza)) await handler.callback(stanza, StanzaHandlerData(false, false, null, stanza));
} }
} }