1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Call connection created listeners in constructor

Fixes SMACK-638.
This commit is contained in:
Florian Schmaus 2015-03-17 12:06:55 +01:00
parent 5188c6f934
commit f410ece468
3 changed files with 4 additions and 21 deletions

View file

@ -31,7 +31,6 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.ConnectionException; import org.jivesoftware.smack.SmackException.ConnectionException;
import org.jivesoftware.smack.XMPPException.StreamErrorException; import org.jivesoftware.smack.XMPPException.StreamErrorException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
@ -435,9 +434,6 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
connected = true; connected = true;
if (isFirstInitialization) { if (isFirstInitialization) {
isFirstInitialization = false; isFirstInitialization = false;
for (ConnectionCreationListener listener : getConnectionCreationListeners()) {
listener.connectionCreated(XMPPBOSHConnection.this);
}
} }
else { else {
if (wasAuthenticated) { if (wasAuthenticated) {

View file

@ -102,15 +102,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
SmackConfiguration.getVersion(); SmackConfiguration.getVersion();
} }
/**
* Get the collection of listeners that are interested in connection creation events.
*
* @return a collection of listeners interested on new connections.
*/
protected static Collection<ConnectionCreationListener> getConnectionCreationListeners() {
return XMPPConnectionRegistry.getConnectionCreationListeners();
}
/** /**
* A collection of ConnectionListeners which listen for connection closing * A collection of ConnectionListeners which listen for connection closing
* and reconnection events. * and reconnection events.
@ -302,6 +293,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/ */
protected AbstractXMPPConnection(ConnectionConfiguration configuration) { protected AbstractXMPPConnection(ConnectionConfiguration configuration) {
config = configuration; config = configuration;
// Notify listeners that a new connection has been established
for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) {
listener.connectionCreated(this);
}
} }
protected ConnectionConfiguration getConfiguration() { protected ConnectionConfiguration getConfiguration() {

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smack.tcp;
import org.jivesoftware.smack.AbstractXMPPConnection; import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.StanzaListener; import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
@ -633,13 +632,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// Start the packet reader. The startup() method will block until we // Start the packet reader. The startup() method will block until we
// get an opening stream packet back from server // get an opening stream packet back from server
packetReader.init(); packetReader.init();
if (isFirstInitialization) {
// Notify listeners that a new connection has been established
for (ConnectionCreationListener listener : getConnectionCreationListeners()) {
listener.connectionCreated(this);
}
}
} }
private void initReaderAndWriter() throws IOException { private void initReaderAndWriter() throws IOException {