1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 20:12:07 +01:00

Make connect() return a self-reference

This commit is contained in:
Florian Schmaus 2015-01-25 19:48:52 +01:00
parent 780872f2ef
commit 1407f10f7f
2 changed files with 5 additions and 3 deletions

View file

@ -13,8 +13,8 @@ Smack Key Advantages
```java ```java
AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org"); AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");
connection.connect(); connection.connect().login();
connection.login();
Chat chat = ChatManager.getInstanceFor(connection) Chat chat = ChatManager.getInstanceFor(connection)
.createChat("jsmith@jivesoftware.com", new MessageListener() { .createChat("jsmith@jivesoftware.com", new MessageListener() {

View file

@ -378,13 +378,15 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws SmackException if an error occurs somewhere else besides XMPP protocol level. * @throws SmackException if an error occurs somewhere else besides XMPP protocol level.
* @throws IOException * @throws IOException
* @throws ConnectionException with detailed information about the failed connection. * @throws ConnectionException with detailed information about the failed connection.
* @return a reference to this object, to chain <code>connect()</code> with <code>login()</code>.
*/ */
public synchronized void connect() throws SmackException, IOException, XMPPException { public synchronized AbstractXMPPConnection connect() throws SmackException, IOException, XMPPException {
throwAlreadyConnectedExceptionIfAppropriate(); throwAlreadyConnectedExceptionIfAppropriate();
saslAuthentication.init(); saslAuthentication.init();
saslFeatureReceived.init(); saslFeatureReceived.init();
lastFeaturesReceived.init(); lastFeaturesReceived.init();
connectInternal(); connectInternal();
return this;
} }
/** /**