chore(example): switch to connectAwaitable
That way it only acts connected when the credentials have been accepted. Also I had to correct the value of "allowPlainAuth" which should be true since a bug with it has been identified, and not yet fixed. Signed-off-by: Blake Leonard <me@blakes.dev>
This commit is contained in:
parent
7b215d5c6e
commit
60c89e28d3
@ -87,7 +87,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
SaslScramNegotiator(8, '', '', ScramHashType.sha1),
|
SaslScramNegotiator(8, '', '', ScramHashType.sha1),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _buttonPressed() async {
|
Future<void> _buttonPressed() async {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
await connection.disconnect();
|
await connection.disconnect();
|
||||||
@ -100,13 +100,22 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
jid: JID.fromString(jidController.text),
|
jid: JID.fromString(jidController.text),
|
||||||
password: passwordController.text,
|
password: passwordController.text,
|
||||||
useDirectTLS: true,
|
useDirectTLS: true,
|
||||||
allowPlainAuth: false,
|
allowPlainAuth: true,
|
||||||
// otherwise, connecting to some servers will
|
// otherwise, connecting to some servers will
|
||||||
// cause an app to hang
|
// cause an app to hang
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await connection.connect();
|
final result = await connection.connectAwaitable();
|
||||||
setState(() {connected = true; loading = false;});
|
setState(() {connected = result.success; loading = false;});
|
||||||
|
if (result.error != null) {
|
||||||
|
print(result.error);
|
||||||
|
if (context.mounted) {
|
||||||
|
showDialog(context: context, builder: (_) => AlertDialog(
|
||||||
|
title: const Text('Error'),
|
||||||
|
content: Text(result.error.toString()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
Reference in New Issue
Block a user