From 12f758e1e27e67410802efb486669ba39fcf0314 Mon Sep 17 00:00:00 2001 From: vsevex Date: Tue, 20 Aug 2024 00:44:03 +0400 Subject: [PATCH] feat: minimal demonstration of the package --- example/main.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/example/main.dart b/example/main.dart index 708ad8c..1322140 100644 --- a/example/main.dart +++ b/example/main.dart @@ -2,15 +2,16 @@ import 'package:whixp/whixp.dart'; void main() { final whixp = Whixp( - 'vsevex@example.com/desktop', - 'passwd', - host: 'example.com', - logger: Log(enableError: true, enableWarning: true), + jabberID: 'vsevex@localhost', + password: 'vesevu13', + logger: Log(enableWarning: true, enableError: true, includeTimestamp: true), + internalDatabasePath: 'whixp', + reconnectionPolicy: RandomBackoffReconnectionPolicy(1, 3), ); - whixp.connect(); - whixp.addEventHandler('sessionStart', (_) { - whixp.getRoster(); - whixp.sendPresence(); + /// Reconnect on disconnection. + whixp.addEventHandler('state', (state) { + if (state == TransportState.disconnected) whixp.connect(); }); + whixp.connect(); }