Skip to content

Commit

Permalink
feat(core): Make all managers optional
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaTutuWawa committed Apr 4, 2023
1 parent f6efa20 commit 7f35388
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 38 deletions.
4 changes: 0 additions & 4 deletions integration_tests/test/component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ void main() {
host: '127.0.0.1',
port: 8888,
);
await conn.registerManagers([
RosterManager(TestingRosterStateManager('', [])),
DiscoManager([]),
]);

final result = await conn.connect(
waitUntilLogin: true,
Expand Down
34 changes: 4 additions & 30 deletions packages/moxxmpp/lib/src/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,14 @@ class XmppConnection {
return getManagerById(presenceManager);
}

/// A [DiscoManager] is required so, have a wrapper for getting it.
/// Returns the registered [DiscoManager].
DiscoManager getDiscoManager() {
assert(
_xmppManagers.containsKey(discoManager),
'A DiscoManager is mandatory',
);

return getManagerById(discoManager)!;
DiscoManager? getDiscoManager() {
return getManagerById<DiscoManager>(discoManager);
}

/// A [RosterManager] is required, so have a wrapper for getting it.
/// Returns the registered [RosterManager].
RosterManager getRosterManager() {
assert(
_xmppManagers.containsKey(rosterManager),
'A RosterManager is mandatory',
);

return getManagerById(rosterManager)!;
RosterManager? getRosterManager() {
return getManagerById<RosterManager>(rosterManager);
}

/// Returns the registered [StreamManagementManager], if one is registered.
Expand Down Expand Up @@ -845,18 +833,6 @@ class XmppConnection {
}
}

/// Make sure that all required managers are registered
void _runPreConnectionAssertions() {
assert(
_xmppManagers.containsKey(rosterManager),
'A RosterManager is mandatory',
);
assert(
_xmppManagers.containsKey(discoManager),
'A DiscoManager is mandatory',
);
}

/// The private implementation for [XmppConnection.connect]. The parameters have
/// the same meaning as with [XmppConnection.connect].
Future<Result<bool, XmppError>> _connectImpl({
Expand Down Expand Up @@ -957,8 +933,6 @@ class XmppConnection {
bool waitUntilLogin = false,
bool enableReconnectOnSuccess = true,
}) async {
_runPreConnectionAssertions();

final result = _connectImpl(
lastResource: lastResource,
shouldReconnect: shouldReconnect ?? !waitUntilLogin,
Expand Down
4 changes: 0 additions & 4 deletions packages/moxxmpp/test/component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ void main() {
jid: JID.fromString('component.example.org'),
password: 'abc123',
);
await conn.registerManagers([
RosterManager(TestingRosterStateManager('', [])),
DiscoManager([]),
]);
final result = await conn.connect(
waitUntilLogin: true,
);
Expand Down

0 comments on commit 7f35388

Please sign in to comment.