feat(core): Make all managers optional
This commit is contained in:
parent
f6efa20ff4
commit
7f3538875b
@ -31,10 +31,6 @@ void main() {
|
|||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: 8888,
|
port: 8888,
|
||||||
);
|
);
|
||||||
await conn.registerManagers([
|
|
||||||
RosterManager(TestingRosterStateManager('', [])),
|
|
||||||
DiscoManager([]),
|
|
||||||
]);
|
|
||||||
|
|
||||||
final result = await conn.connect(
|
final result = await conn.connect(
|
||||||
waitUntilLogin: true,
|
waitUntilLogin: true,
|
||||||
|
@ -262,26 +262,14 @@ class XmppConnection {
|
|||||||
return getManagerById(presenceManager);
|
return getManagerById(presenceManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [DiscoManager] is required so, have a wrapper for getting it.
|
|
||||||
/// Returns the registered [DiscoManager].
|
/// Returns the registered [DiscoManager].
|
||||||
DiscoManager getDiscoManager() {
|
DiscoManager? getDiscoManager() {
|
||||||
assert(
|
return getManagerById<DiscoManager>(discoManager);
|
||||||
_xmppManagers.containsKey(discoManager),
|
|
||||||
'A DiscoManager is mandatory',
|
|
||||||
);
|
|
||||||
|
|
||||||
return getManagerById(discoManager)!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [RosterManager] is required, so have a wrapper for getting it.
|
|
||||||
/// Returns the registered [RosterManager].
|
/// Returns the registered [RosterManager].
|
||||||
RosterManager getRosterManager() {
|
RosterManager? getRosterManager() {
|
||||||
assert(
|
return getManagerById<RosterManager>(rosterManager);
|
||||||
_xmppManagers.containsKey(rosterManager),
|
|
||||||
'A RosterManager is mandatory',
|
|
||||||
);
|
|
||||||
|
|
||||||
return getManagerById(rosterManager)!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the registered [StreamManagementManager], if one is registered.
|
/// Returns the registered [StreamManagementManager], if one is registered.
|
||||||
@ -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 private implementation for [XmppConnection.connect]. The parameters have
|
||||||
/// the same meaning as with [XmppConnection.connect].
|
/// the same meaning as with [XmppConnection.connect].
|
||||||
Future<Result<bool, XmppError>> _connectImpl({
|
Future<Result<bool, XmppError>> _connectImpl({
|
||||||
@ -957,8 +933,6 @@ class XmppConnection {
|
|||||||
bool waitUntilLogin = false,
|
bool waitUntilLogin = false,
|
||||||
bool enableReconnectOnSuccess = true,
|
bool enableReconnectOnSuccess = true,
|
||||||
}) async {
|
}) async {
|
||||||
_runPreConnectionAssertions();
|
|
||||||
|
|
||||||
final result = _connectImpl(
|
final result = _connectImpl(
|
||||||
lastResource: lastResource,
|
lastResource: lastResource,
|
||||||
shouldReconnect: shouldReconnect ?? !waitUntilLogin,
|
shouldReconnect: shouldReconnect ?? !waitUntilLogin,
|
||||||
|
@ -35,10 +35,6 @@ void main() {
|
|||||||
jid: JID.fromString('component.example.org'),
|
jid: JID.fromString('component.example.org'),
|
||||||
password: 'abc123',
|
password: 'abc123',
|
||||||
);
|
);
|
||||||
await conn.registerManagers([
|
|
||||||
RosterManager(TestingRosterStateManager('', [])),
|
|
||||||
DiscoManager([]),
|
|
||||||
]);
|
|
||||||
final result = await conn.connect(
|
final result = await conn.connect(
|
||||||
waitUntilLogin: true,
|
waitUntilLogin: true,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user