Compare commits

..

No commits in common. "7f3538875be727f28126d39edff705d2f254baad" and "8443411f07aa48573e358556b66a8ded52419438" have entirely different histories.

7 changed files with 45 additions and 11 deletions

View File

@ -16,10 +16,10 @@ dependencies:
version: 0.1.4+1
moxxmpp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.3.0
version: 0.1.6+1
moxxmpp_socket_tcp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.3.0
version: 0.1.2+9
dev_dependencies:
flutter_test:

View File

@ -7,8 +7,8 @@ environment:
dependencies:
logging: ^1.0.2
moxxmpp: 0.3.0
moxxmpp_socket_tcp: 0.3.0
moxxmpp: 0.2.0
moxxmpp_socket_tcp: 0.2.1
dev_dependencies:
lints: ^2.0.0

View File

@ -31,6 +31,10 @@ void main() {
host: '127.0.0.1',
port: 8888,
);
await conn.registerManagers([
RosterManager(TestingRosterStateManager('', [])),
DiscoManager([]),
]);
final result = await conn.connect(
waitUntilLogin: true,

View File

@ -9,7 +9,7 @@ Include the following as a dependency in your pubspec file:
```
moxxmpp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: 0.3.0
version: 0.2.0
```
You can find the documentation [here](https://moxxy.org/developers/docs/moxxmpp/).

View File

@ -262,14 +262,26 @@ class XmppConnection {
return getManagerById(presenceManager);
}
/// A [DiscoManager] is required so, have a wrapper for getting it.
/// Returns the registered [DiscoManager].
DiscoManager? getDiscoManager() {
return getManagerById<DiscoManager>(discoManager);
DiscoManager getDiscoManager() {
assert(
_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].
RosterManager? getRosterManager() {
return getManagerById<RosterManager>(rosterManager);
RosterManager getRosterManager() {
assert(
_xmppManagers.containsKey(rosterManager),
'A RosterManager is mandatory',
);
return getManagerById(rosterManager)!;
}
/// Returns the registered [StreamManagementManager], if one is registered.
@ -833,6 +845,18 @@ 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({
@ -933,6 +957,8 @@ class XmppConnection {
bool waitUntilLogin = false,
bool enableReconnectOnSuccess = true,
}) async {
_runPreConnectionAssertions();
final result = _connectImpl(
lastResource: lastResource,
shouldReconnect: shouldReconnect ?? !waitUntilLogin,

View File

@ -35,6 +35,10 @@ void main() {
jid: JID.fromString('component.example.org'),
password: 'abc123',
);
await conn.registerManagers([
RosterManager(TestingRosterStateManager('', [])),
DiscoManager([]),
]);
final result = await conn.connect(
waitUntilLogin: true,
);

View File

@ -1,6 +1,6 @@
name: moxxmpp_socket_tcp
description: A socket for moxxmpp using TCP that implements the RFC6120 connection algorithm and XEP-0368
version: 0.3.0
version: 0.2.1
homepage: https://codeberg.org/moxxy/moxxmpp
publish_to: https://git.polynom.me/api/packages/Moxxy/pub
@ -12,7 +12,7 @@ dependencies:
meta: ^1.6.0
moxxmpp:
hosted: https://git.polynom.me/api/packages/Moxxy/pub
version: ^0.3.0
version: ^0.2.0
dev_dependencies:
lints: ^2.0.0