parent
902b497526
commit
1000e0756b
@ -791,6 +791,10 @@ class XmppConnection {
|
||||
_connectionCompleter?.complete(const XmppConnectionResult(true));
|
||||
_connectionCompleter = null;
|
||||
|
||||
// Tell consumers of the event stream that we're done with stream feature
|
||||
// negotiations
|
||||
await _sendEvent(StreamNegotiationsDoneEvent());
|
||||
|
||||
// Send out initial presence
|
||||
await getPresenceManager().sendInitialPresence();
|
||||
}
|
||||
|
@ -246,3 +246,6 @@ class NonRecoverableErrorEvent extends XmppEvent {
|
||||
/// The error in question.
|
||||
final XmppError error;
|
||||
}
|
||||
|
||||
/// Triggered when the stream negotiations are done.
|
||||
class StreamNegotiationsDoneEvent extends XmppEvent {}
|
||||
|
@ -8,6 +8,7 @@ import 'package:moxxmpp/src/managers/namespaces.dart';
|
||||
import 'package:moxxmpp/src/stringxml.dart';
|
||||
import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
|
||||
import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
||||
import 'package:moxxmpp/src/xeps/xep_0198/xep_0198.dart';
|
||||
|
||||
abstract class XmppManagerBase {
|
||||
XmppManagerBase(this.id);
|
||||
@ -111,6 +112,15 @@ abstract class XmppManagerBase {
|
||||
return handled;
|
||||
}
|
||||
|
||||
/// Returns true, if the current stream negotiations resulted in a new stream. Useful
|
||||
/// for plugins to reset their cache in case of a new stream.
|
||||
/// The value only makes sense after receiving a StreamNegotiationsDoneEvent.
|
||||
Future<bool> isNewStream() async {
|
||||
final sm = getAttributes().getManagerById<StreamManagementManager>(smManager);
|
||||
|
||||
return sm?.streamResumed == false;
|
||||
}
|
||||
|
||||
/// Sends a reply of the stanza in [data] with [type]. Replaces the original stanza's
|
||||
/// children with [children].
|
||||
///
|
||||
|
@ -46,11 +46,14 @@ class BlockingManager extends XmppManagerBase {
|
||||
|
||||
@override
|
||||
Future<void> onXmppEvent(XmppEvent event) async {
|
||||
if (event is StreamResumeFailedEvent) {
|
||||
if (event is StreamNegotiationsDoneEvent) {
|
||||
final newStream = await isNewStream();
|
||||
if (newStream) {
|
||||
_gotSupported = false;
|
||||
_supported = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<StanzaHandlerData> _blockPush(Stanza iq, StanzaHandlerData state) async {
|
||||
final block = iq.firstTag('block', xmlns: blockingXmlns)!;
|
||||
|
@ -59,21 +59,15 @@ class CarbonsManager extends XmppManagerBase {
|
||||
|
||||
@override
|
||||
Future<void> onXmppEvent(XmppEvent event) async {
|
||||
if (event is ServerDiscoDoneEvent && !_isEnabled) {
|
||||
final attrs = getAttributes();
|
||||
|
||||
if (attrs.isFeatureSupported(carbonsXmlns)) {
|
||||
logger.finest('Message carbons supported. Enabling...');
|
||||
await enableCarbons();
|
||||
logger.finest('Message carbons enabled');
|
||||
} else {
|
||||
logger.info('Message carbons not supported.');
|
||||
}
|
||||
} else if (event is StreamResumeFailedEvent) {
|
||||
if (event is StreamNegotiationsDoneEvent) {
|
||||
// Reset disco cache info on a new stream
|
||||
final newStream = await isNewStream();
|
||||
if (newStream) {
|
||||
_gotSupported = false;
|
||||
_supported = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<StanzaHandlerData> _onMessageReceived(Stanza message, StanzaHandlerData state) async {
|
||||
final from = JID.fromString(message.attributes['from']! as String);
|
||||
|
@ -77,13 +77,16 @@ class HttpFileUploadManager extends XmppManagerBase {
|
||||
|
||||
@override
|
||||
Future<void> onXmppEvent(XmppEvent event) async {
|
||||
if (event is StreamResumeFailedEvent) {
|
||||
if (event is StreamNegotiationsDoneEvent) {
|
||||
final newStream = await isNewStream();
|
||||
if (newStream) {
|
||||
_gotSupported = false;
|
||||
_supported = false;
|
||||
_entityJid = null;
|
||||
_maxUploadSize = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> isSupported() async {
|
||||
|
@ -1 +0,0 @@
|
||||
/nix/store/df027433sc5k93yfsm823wl42vijhrzn-lol-pub-cache
|
Loading…
Reference in New Issue
Block a user