feat(core): Make the PresenceManager optional
This commit is contained in:
parent
9358175925
commit
89fe8f0a9c
@ -5,6 +5,7 @@
|
|||||||
- **BREAKING**: The user avatar's `subscribe` and `unsubscribe` no longer subscribe to the `:data` PubSub nodes
|
- **BREAKING**: The user avatar's `subscribe` and `unsubscribe` no longer subscribe to the `:data` PubSub nodes
|
||||||
- Renamed `ResourceBindingSuccessEvent` to `ResourceBoundEvent`
|
- Renamed `ResourceBindingSuccessEvent` to `ResourceBoundEvent`
|
||||||
- **BREAKING**: Removed `isFeatureSupported` from the manager attributes. The managers now all have a method `isFeatureSupported` that works the same
|
- **BREAKING**: Removed `isFeatureSupported` from the manager attributes. The managers now all have a method `isFeatureSupported` that works the same
|
||||||
|
- The `PresenceManager` is now optional
|
||||||
|
|
||||||
## 0.1.6+1
|
## 0.1.6+1
|
||||||
|
|
||||||
|
@ -861,9 +861,6 @@ class XmppConnection {
|
|||||||
// Tell consumers of the event stream that we're done with stream feature
|
// Tell consumers of the event stream that we're done with stream feature
|
||||||
// negotiations
|
// negotiations
|
||||||
await _sendEvent(StreamNegotiationsDoneEvent());
|
await _sendEvent(StreamNegotiationsDoneEvent());
|
||||||
|
|
||||||
// Send out initial presence
|
|
||||||
await getPresenceManager().sendInitialPresence();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _executeCurrentNegotiator(XMLNode nonza) async {
|
Future<void> _executeCurrentNegotiator(XMLNode nonza) async {
|
||||||
@ -1090,10 +1087,6 @@ class XmppConnection {
|
|||||||
|
|
||||||
/// Make sure that all required managers are registered
|
/// Make sure that all required managers are registered
|
||||||
void _runPreConnectionAssertions() {
|
void _runPreConnectionAssertions() {
|
||||||
assert(
|
|
||||||
_xmppManagers.containsKey(presenceManager),
|
|
||||||
'A PresenceManager is mandatory',
|
|
||||||
);
|
|
||||||
assert(
|
assert(
|
||||||
_xmppManagers.containsKey(rosterManager),
|
_xmppManagers.containsKey(rosterManager),
|
||||||
'A RosterManager is mandatory',
|
'A RosterManager is mandatory',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'package:moxxmpp/src/connection.dart';
|
import 'package:moxxmpp/src/connection.dart';
|
||||||
import 'package:moxxmpp/src/events.dart';
|
import 'package:moxxmpp/src/events.dart';
|
||||||
import 'package:moxxmpp/src/jid.dart';
|
import 'package:moxxmpp/src/jid.dart';
|
||||||
@ -6,8 +7,10 @@ import 'package:moxxmpp/src/managers/data.dart';
|
|||||||
import 'package:moxxmpp/src/managers/handlers.dart';
|
import 'package:moxxmpp/src/managers/handlers.dart';
|
||||||
import 'package:moxxmpp/src/managers/namespaces.dart';
|
import 'package:moxxmpp/src/managers/namespaces.dart';
|
||||||
import 'package:moxxmpp/src/namespaces.dart';
|
import 'package:moxxmpp/src/namespaces.dart';
|
||||||
|
import 'package:moxxmpp/src/negotiators/namespaces.dart';
|
||||||
import 'package:moxxmpp/src/stanza.dart';
|
import 'package:moxxmpp/src/stanza.dart';
|
||||||
import 'package:moxxmpp/src/stringxml.dart';
|
import 'package:moxxmpp/src/stringxml.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0198/negotiator.dart';
|
||||||
|
|
||||||
/// A function that will be called when presence, outside of subscription request
|
/// A function that will be called when presence, outside of subscription request
|
||||||
/// management, will be sent. Useful for managers that want to add [XMLNode]s to said
|
/// management, will be sent. Useful for managers that want to add [XMLNode]s to said
|
||||||
@ -42,6 +45,19 @@ class PresenceManager extends XmppManagerBase {
|
|||||||
_presenceCallbacks.add(callback);
|
_presenceCallbacks.add(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onXmppEvent(XmppEvent event) async {
|
||||||
|
if (event is StreamNegotiationsDoneEvent) {
|
||||||
|
// Send initial presence only when we have not resumed the stream
|
||||||
|
final sm = getAttributes().getNegotiatorById<StreamManagementNegotiator>(
|
||||||
|
streamManagementNegotiator);
|
||||||
|
final isResumed = sm?.isResumed ?? false;
|
||||||
|
if (!isResumed) {
|
||||||
|
unawaited(sendInitialPresence());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<StanzaHandlerData> _onPresence(
|
Future<StanzaHandlerData> _onPresence(
|
||||||
Stanza presence,
|
Stanza presence,
|
||||||
StanzaHandlerData state,
|
StanzaHandlerData state,
|
||||||
|
@ -431,7 +431,7 @@ void main() {
|
|||||||
await conn.connect(
|
await conn.connect(
|
||||||
waitUntilLogin: true,
|
waitUntilLogin: true,
|
||||||
);
|
);
|
||||||
expect(fakeSocket.getState(), 5);
|
expect(fakeSocket.getState(), 6);
|
||||||
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
||||||
expect(
|
expect(
|
||||||
conn
|
conn
|
||||||
@ -589,7 +589,7 @@ void main() {
|
|||||||
waitUntilLogin: true,
|
waitUntilLogin: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(fakeSocket.getState(), 5);
|
expect(fakeSocket.getState(), 6);
|
||||||
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
||||||
expect(
|
expect(
|
||||||
conn
|
conn
|
||||||
@ -689,7 +689,7 @@ void main() {
|
|||||||
await conn.connect(
|
await conn.connect(
|
||||||
waitUntilLogin: true,
|
waitUntilLogin: true,
|
||||||
);
|
);
|
||||||
expect(fakeSocket.getState(), 6);
|
expect(fakeSocket.getState(), 7);
|
||||||
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
expect(await conn.getConnectionState(), XmppConnectionState.connected);
|
||||||
expect(
|
expect(
|
||||||
conn
|
conn
|
||||||
|
Loading…
Reference in New Issue
Block a user