From 85c5f18a09b8d523599ea8d1058e17172ae5b372 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Fri, 24 Oct 2008 02:31:41 +0000 Subject: [PATCH] Added section about connection, disconnection and reconnection. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10842 b35dd754-fafc-0310-a699-88a17e54d16e --- documentation/connections.html | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/documentation/connections.html b/documentation/connections.html index 2539dda35..173edd6ac 100644 --- a/documentation/connections.html +++ b/documentation/connections.html @@ -55,14 +55,39 @@ Connect and Disconnect

+
+
+// Create the configuration for this new connection
+ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222);
+config.setCompressionEnabled(true);
+config.setSASLAuthenticationEnabled(true);
 
+XMPPConnection connection = new XMPPConnection(config);
+// Connect to the server
+connection.connect();
+// Log into the server
+connection.login("username", "password", "SomeResource");
+....
+// Disconnect from the server
+connection.disconnect();
+
- +

+By default Smack will try to reconnect the connection in case it was abruptly disconnected. Use +ConnectionConfiguration#setReconnectionAllowed(boolean) to turn on/off this feature. The reconnection +manager will try to immediately reconnect to the server and increase the delay between attempts as +successive reconnections keep failing. +
+In case you want to force a reconnection while the reconnetion manager is waiting for the next +reconnection, you can just use XMPPConnection#connect() and a new attempt will be made. +If the manual attempt also failed then the reconnection manager will still continue the +reconnection job. +