diff --git a/documentation/overview.md b/documentation/overview.md
index 4b2976385..0ce78d4e1 100644
--- a/documentation/overview.md
+++ b/documentation/overview.md
@@ -13,8 +13,8 @@ Smack Key Advantages
```java
AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");
- connection.connect();
- connection.login();
+ connection.connect().login();
+
Chat chat = ChatManager.getInstanceFor(connection)
.createChat("jsmith@jivesoftware.com", new MessageListener() {
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
index 6ff0bcb96..349df3f17 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
@@ -378,13 +378,15 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws SmackException if an error occurs somewhere else besides XMPP protocol level.
* @throws IOException
* @throws ConnectionException with detailed information about the failed connection.
+ * @return a reference to this object, to chain connect()
with login()
.
*/
- public synchronized void connect() throws SmackException, IOException, XMPPException {
+ public synchronized AbstractXMPPConnection connect() throws SmackException, IOException, XMPPException {
throwAlreadyConnectedExceptionIfAppropriate();
saslAuthentication.init();
saslFeatureReceived.init();
lastFeaturesReceived.init();
connectInternal();
+ return this;
}
/**