From 1407f10f7f115416b554f7f3b2b640b2ea09c21f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 25 Jan 2015 19:48:52 +0100 Subject: [PATCH] Make connect() return a self-reference --- documentation/overview.md | 4 ++-- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) 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; } /**