public abstract class AbstractXMPPConnection extends Object implements XMPPConnection
| Modifier and Type | Class and Description | 
|---|---|
| protected static class  | AbstractXMPPConnection.InterceptorWrapperA wrapper class to associate a stanza(/packet) filter with an interceptor. | 
| protected static class  | AbstractXMPPConnection.ListenerWrapperA wrapper class to associate a stanza(/packet) filter with a listener. | 
XMPPConnection.FromMode| Modifier and Type | Field and Description | 
|---|---|
| protected boolean | authenticatedFlag that indicates if the user is currently authenticated with the server. | 
| protected XMPPInputOutputStream | compressionHandler | 
| protected ConnectionConfiguration | configHolds the initial configuration used while creating the connection. | 
| protected boolean | connected | 
| protected int | connectionCounterValueA number to uniquely identify connections that are created. | 
| protected Set<ConnectionListener> | connectionListenersA collection of ConnectionListeners which listen for connection closing
 and reconnection events. | 
| protected Lock | connectionLock | 
| protected SmackDebugger | debuggerThe SmackDebugger allows to log and debug XML traffic. | 
| protected String | hostThe used host to establish the connection to | 
| protected List<HostAddress> | hostAddresses | 
| protected SynchronizationPoint<Exception> | lastFeaturesReceivedSet to success if the last features stanza from the server has been parsed. | 
| protected int | portThe used port to establish the connection to | 
| protected Reader | readerThe Reader which is used for the debugger. | 
| protected SASLAuthentication | saslAuthenticationThe SASLAuthentication manager that is responsible for authenticating with the server. | 
| protected SynchronizationPoint<SmackException> | saslFeatureReceivedSet to success if the sasl feature has been received. | 
| protected Map<String,ExtensionElement> | streamFeatures | 
| protected String | streamIdThe stream ID, see RFC 6120 ยง 4.7.3 | 
| protected String | userThe full JID of the authenticated user, as returned by the resource binding response of the server. | 
| protected boolean | wasAuthenticatedFlag that indicates if the user was authenticated with the server when the connection
 to the server was closed (abruptly or not). | 
| protected Writer | writerThe Writer which is used for the debugger. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | AbstractXMPPConnection(ConnectionConfiguration configuration)Create a new XMPPConnection to an XMPP server. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addAsyncStanzaListener(StanzaListener packetListener,
                      StanzaFilter packetFilter)Registers an asynchronous stanza(/packet) listener with this connection. | 
| void | addConnectionListener(ConnectionListener connectionListener)Adds a connection listener to this connection that will be notified when
 the connection closes or fails. | 
| void | addOneTimeSyncCallback(StanzaListener callback,
                      StanzaFilter packetFilter)Add a callback that is called exactly once and synchronously with the incoming stanza that matches the given
 stanza(/packet) filter. | 
| void | addPacketInterceptor(StanzaListener packetInterceptor,
                    StanzaFilter packetFilter)Registers a stanza(/packet) interceptor with this connection. | 
| void | addPacketListener(StanzaListener packetListener,
                 StanzaFilter packetFilter)Deprecated.  | 
| void | addPacketSendingListener(StanzaListener packetListener,
                        StanzaFilter packetFilter)Registers a stanza(/packet) listener with this connection. | 
| void | addSyncStanzaListener(StanzaListener packetListener,
                     StanzaFilter packetFilter)Registers a synchronous stanza(/packet) listener with this connection. | 
| protected void | afterFeaturesReceived() | 
| protected void | afterSuccessfulLogin(boolean resumed) | 
| protected void | asyncGo(Runnable runnable) | 
| protected void | bindResourceAndEstablishSession(String resource) | 
| protected void | callConnectionAuthenticatedListener(boolean resumed) | 
| protected void | callConnectionClosedOnErrorListener(Exception e) | 
| protected void | callConnectionConnectedListener() | 
| AbstractXMPPConnection | connect()Establishes a connection to the XMPP server and performs an automatic login
 only if the previous connection state was logged (authenticated). | 
| protected abstract void | connectInternal()Abstract method that concrete subclasses of XMPPConnection need to implement to perform their
 way of XMPP connection establishment. | 
| PacketCollector | createPacketCollector(PacketCollector.Configuration configuration)Create a new stanza(/packet) collector with the given stanza(/packet) collector configuration. | 
| PacketCollector | createPacketCollector(StanzaFilter packetFilter)Creates a new stanza(/packet) collector for this connection. | 
| PacketCollector | createPacketCollectorAndSend(IQ packet)Creates a new stanza(/packet) collector collecting packets that are replies to  packet. | 
| PacketCollector | createPacketCollectorAndSend(StanzaFilter packetFilter,
                            Stanza packet)Creates a new stanza(/packet) collector for this connection. | 
| void | disconnect()Closes the connection by setting presence to unavailable then closing the connection to
 the XMPP server. | 
| void | disconnect(Presence unavailablePresence)Closes the connection. | 
| protected void | finalize() | 
| protected void | firePacketSendingListeners(Stanza packet)Process all stanza(/packet) listeners for sending packets. | 
| ConnectionConfiguration | getConfiguration()Get the connection configuration used by this connection. | 
| int | getConnectionCounter()Get the connection counter of this XMPPConnection instance. | 
| protected static Collection<ConnectionCreationListener> | getConnectionCreationListeners()Get the collection of listeners that are interested in connection creation events. | 
| protected Lock | getConnectionLock() | 
| <F extends ExtensionElement> | getFeature(String element,
          String namespace)Get the feature stanza(/packet) extensions for a given stream feature of the
 server, or  nullif the server doesn't support that feature. | 
| XMPPConnection.FromMode | getFromMode()Get the currently active FromMode. | 
| String | getHost()Returns the host name of the server where the XMPP server is running. | 
| long | getLastStanzaReceived()Returns the timestamp in milliseconds when the last stanza was received. | 
| long | getPacketReplyTimeout()Returns the current value of the reply timeout in milliseconds for request for this
 XMPPConnection instance. | 
| ParsingExceptionCallback | getParsingExceptionCallback()Get the current active parsing exception callback. | 
| int | getPort()Returns the port number of the XMPP server for this connection. | 
| protected SASLAuthentication | getSASLAuthentication()Returns the SASLAuthentication manager that is responsible for authenticating with
 the server. | 
| String | getServiceName()Returns the name of the service provided by the XMPP server for this connection. | 
| String | getStreamId()Returns the stream ID for this connection, which is the value set by the server
 when opening an XMPP stream. | 
| String | getUser()Returns the full XMPP address of the user that is logged in to the connection or
 null if not logged in yet. | 
| boolean | hasFeature(String element,
          String namespace)Return true if the server supports the given stream feature. | 
| protected void | initDebugger()Initialize the  debugger. | 
| protected void | invokePacketCollectorsAndNotifyRecvListeners(Stanza packet)Invoke  PacketCollector.processPacket(Stanza)for every
 PacketCollector with the given packet. | 
| boolean | isAnonymous()Returns true if currently authenticated anonymously. | 
| boolean | isAuthenticated()Returns true if currently authenticated by successfully calling the login method. | 
| boolean | isConnected()Returns true if currently connected to the XMPP server. | 
| abstract boolean | isSecureConnection()Returns true if the connection to the server has successfully negotiated encryption. | 
| abstract boolean | isUsingCompression()Returns true if network traffic is being compressed. | 
| void | login()Logs in to the server using the strongest SASL mechanism supported by
 the server. | 
| void | login(CharSequence username,
     String password)Same as  login(CharSequence, String, String), but takes the resource from the connection
 configuration. | 
| void | login(CharSequence username,
     String password,
     String resource)Login with the given username (authorization identity). | 
| protected abstract void | loginAnonymously() | 
| protected abstract void | loginNonAnonymously(String username,
                   String password,
                   String resource) | 
| protected void | notifyReconnection()Sends a notification indicating that the connection was reconnected successfully. | 
| protected void | parseAndProcessStanza(org.xmlpull.v1.XmlPullParser parser) | 
| protected void | parseFeatures(org.xmlpull.v1.XmlPullParser parser) | 
| protected List<HostAddress> | populateHostAddresses()Populates  hostAddresseswith at least one host address. | 
| protected void | processPacket(Stanza packet)Processes a stanza(/packet) after it's been fully parsed by looping through the installed
 stanza(/packet) collectors and listeners and letting them examine the stanza(/packet) to see if
 they are a match with the filter. | 
| IQRequestHandler | registerIQRequestHandler(IQRequestHandler iqRequestHandler)Register an IQ request handler with this connection. | 
| boolean | removeAsyncStanzaListener(StanzaListener packetListener)Removes an asynchronous stanza(/packet) listener for received packets from this connection. | 
| void | removeConnectionListener(ConnectionListener connectionListener)Removes a connection listener from this connection. | 
| void | removePacketCollector(PacketCollector collector)Remove a stanza(/packet) collector of this connection. | 
| void | removePacketInterceptor(StanzaListener packetInterceptor)Removes a stanza(/packet) interceptor. | 
| boolean | removePacketListener(StanzaListener packetListener)Deprecated.  | 
| void | removePacketSendingListener(StanzaListener packetListener)Removes a stanza(/packet) listener for sending packets from this connection. | 
| boolean | removeSyncStanzaListener(StanzaListener packetListener)Removes a stanza(/packet) listener for received packets from this connection. | 
| protected ScheduledFuture<?> | schedule(Runnable runnable,
        long delay,
        TimeUnit unit) | 
| abstract void | send(PlainStreamElement element)Send a PlainStreamElement. | 
| void | sendIqWithResponseCallback(IQ iqRequest,
                          StanzaListener callback)Send a IQ stanza and invoke  callbackif there is a result ofIQ.Type.resultwith that result IQ. | 
| void | sendIqWithResponseCallback(IQ iqRequest,
                          StanzaListener callback,
                          ExceptionCallback exceptionCallback)Send a IQ stanza and invoke  callbackif there is a result ofIQ.Type.resultwith that result IQ. | 
| void | sendIqWithResponseCallback(IQ iqRequest,
                          StanzaListener callback,
                          ExceptionCallback exceptionCallback,
                          long timeout)Send a IQ stanza and invoke  callbackif there is a result ofIQ.Type.resultwith that result IQ. | 
| void | sendPacket(Stanza packet)Deprecated.  | 
| void | sendStanza(Stanza packet)Sends the specified stanza to the server. | 
| protected abstract void | sendStanzaInternal(Stanza packet) | 
| void | sendStanzaWithResponseCallback(Stanza stanza,
                              StanzaFilter replyFilter,
                              StanzaListener callback)Send a stanza and wait asynchronously for a response by using  replyFilter. | 
| void | sendStanzaWithResponseCallback(Stanza stanza,
                              StanzaFilter replyFilter,
                              StanzaListener callback,
                              ExceptionCallback exceptionCallback)Send a stanza and wait asynchronously for a response by using  replyFilter. | 
| void | sendStanzaWithResponseCallback(Stanza stanza,
                              StanzaFilter replyFilter,
                              StanzaListener callback,
                              ExceptionCallback exceptionCallback,
                              long timeout)Send a stanza and wait asynchronously for a response by using  replyFilter. | 
| void | setFromMode(XMPPConnection.FromMode fromMode)Set the FromMode for this connection instance. | 
| void | setPacketReplyTimeout(long timeout)Set the stanza(/packet) reply timeout in milliseconds. | 
| void | setParsingExceptionCallback(ParsingExceptionCallback callback)Install a parsing exception callback, which will be invoked once an exception is encountered while parsing a
 stanza | 
| void | setReplyToUnknownIq(boolean replyToUnknownIq)Set if Smack will automatically send
  XMPPError.Condition.feature_not_implementedwhen a request IQ without a
 registeredIQRequestHandleris received. | 
| static void | setReplyToUnknownIqDefault(boolean replyToUnkownIqDefault)Set the default value used to determine if new connection will reply to unknown IQ requests. | 
| protected void | setWasAuthenticated()Sets whether the connection has already logged in the server. | 
| protected abstract void | shutdown()Shuts the current connection down. | 
| protected void | throwAlreadyConnectedExceptionIfAppropriate() | 
| protected void | throwAlreadyLoggedInExceptionIfAppropriate() | 
| protected void | throwNotConnectedExceptionIfAppropriate() | 
| protected void | throwNotConnectedExceptionIfAppropriate(String optionalHint) | 
| IQRequestHandler | unregisterIQRequestHandler(IQRequestHandler iqRequestHandler)Convenience method for  XMPPConnection.unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type). | 
| IQRequestHandler | unregisterIQRequestHandler(String element,
                          String namespace,
                          IQ.Type type)Unregister an IQ request handler with this connection. | 
protected final Set<ConnectionListener> connectionListeners
protected final Lock connectionLock
protected final Map<String,ExtensionElement> streamFeatures
protected String user
It is important that we don't infer the user from the login() arguments and the configurations service name, as, for example, when SASL External is used, the username is not given to login but taken from the 'external' certificate.
protected boolean connected
protected SmackDebugger debugger
protected final SynchronizationPoint<Exception> lastFeaturesReceived
protected final SynchronizationPoint<SmackException> saslFeatureReceived
protected SASLAuthentication saslAuthentication
protected final int connectionCounterValue
protected final ConnectionConfiguration config
protected XMPPInputOutputStream compressionHandler
protected int port
protected boolean authenticated
protected boolean wasAuthenticated
protected List<HostAddress> hostAddresses
protected AbstractXMPPConnection(ConnectionConfiguration configuration)
configuration - The configuration which is used to establish the connection.protected static Collection<ConnectionCreationListener> getConnectionCreationListeners()
public ConnectionConfiguration getConfiguration()
public String getServiceName()
XMPPConnectiongetServiceName in interface XMPPConnectionpublic String getHost()
XMPPConnectiongetHost in interface XMPPConnectionpublic int getPort()
XMPPConnectiongetPort in interface XMPPConnectionpublic abstract boolean isSecureConnection()
XMPPConnectionisSecureConnection in interface XMPPConnectionprotected abstract void sendStanzaInternal(Stanza packet) throws SmackException.NotConnectedException
public abstract void send(PlainStreamElement element) throws SmackException.NotConnectedException
XMPPConnectionThis method is not meant for end-user usage! It allows sending plain stream elements, which should not be done by a user manually. Doing so may result in a unstable or unusable connection. Certain Smack APIs use this method to send plain stream elements.
send in interface XMPPConnectionSmackException.NotConnectedExceptionpublic abstract boolean isUsingCompression()
XMPPConnectionisUsingCompression in interface XMPPConnectionpublic AbstractXMPPConnection connect() throws SmackException, IOException, XMPPException
Listeners will be preserved from a previous connection.
connect() with login().XMPPException - if an error occurs on the XMPP protocol level.SmackException - if an error occurs somewhere else besides XMPP protocol level.IOExceptionSmackException.ConnectionException - with detailed information about the failed connection.protected abstract void connectInternal() throws SmackException, IOException, XMPPException
SmackExceptionIOExceptionXMPPExceptionpublic void login() throws XMPPException, SmackException, IOException
SmackException.NoResponseException will be thrown.
 
 Before logging in (i.e. authenticate) to the server the connection must be connected
 by calling connect().
 
 It is possible to log in without sending an initial available presence by using
 ConnectionConfiguration.Builder.setSendPresence(boolean).
 Finally, if you want to not pass a password and instead use a more advanced mechanism
 while using SASL then you may be interested in using
 ConnectionConfiguration.Builder.setCallbackHandler(javax.security.auth.callback.CallbackHandler).
 For more advanced login settings see ConnectionConfiguration.
 
XMPPException - if an error occurs on the XMPP protocol level.SmackException - if an error occurs somewhere else besides XMPP protocol level.IOException - if an I/O error occurs during login.public void login(CharSequence username, String password) throws XMPPException, SmackException, IOException
login(CharSequence, String, String), but takes the resource from the connection
 configuration.username - password - XMPPExceptionSmackExceptionIOExceptionlogin()public void login(CharSequence username, String password, String resource) throws XMPPException, SmackException, IOException
username - password - resource - XMPPExceptionSmackExceptionIOExceptionlogin()protected abstract void loginNonAnonymously(String username, String password, String resource) throws XMPPException, SmackException, IOException
XMPPExceptionSmackExceptionIOExceptionprotected abstract void loginAnonymously() throws XMPPException, SmackException, IOException
XMPPExceptionSmackExceptionIOExceptionpublic final boolean isConnected()
XMPPConnectionisConnected in interface XMPPConnectionpublic final boolean isAuthenticated()
XMPPConnectionisAuthenticated in interface XMPPConnectionpublic final String getUser()
XMPPConnectiongetUser in interface XMPPConnectionpublic String getStreamId()
XMPPConnectiongetStreamId in interface XMPPConnectionprotected void bindResourceAndEstablishSession(String resource) throws XMPPException.XMPPErrorException, IOException, SmackException
protected void afterSuccessfulLogin(boolean resumed) throws SmackException.NotConnectedException
public final boolean isAnonymous()
XMPPConnectionisAnonymous in interface XMPPConnectionprotected List<HostAddress> populateHostAddresses()
hostAddresses with at least one host address.protected Lock getConnectionLock()
protected void throwNotConnectedExceptionIfAppropriate() throws SmackException.NotConnectedException
protected void throwNotConnectedExceptionIfAppropriate(String optionalHint) throws SmackException.NotConnectedException
protected void throwAlreadyConnectedExceptionIfAppropriate() throws SmackException.AlreadyConnectedException
protected void throwAlreadyLoggedInExceptionIfAppropriate() throws SmackException.AlreadyLoggedInException
@Deprecated public void sendPacket(Stanza packet) throws SmackException.NotConnectedException
XMPPConnectionsendPacket in interface XMPPConnectionpacket - the stanza(/packet) to send.SmackException.NotConnectedExceptionpublic void sendStanza(Stanza packet) throws SmackException.NotConnectedException
XMPPConnectionsendStanza in interface XMPPConnectionpacket - the stanza to send.SmackException.NotConnectedException - if the connection is not connected.protected SASLAuthentication getSASLAuthentication()
public void disconnect()
public void disconnect(Presence unavailablePresence) throws SmackException.NotConnectedException
unavailablePresence - the presence stanza(/packet) to send during shutdown.SmackException.NotConnectedExceptionprotected abstract void shutdown()
public void addConnectionListener(ConnectionListener connectionListener)
XMPPConnectionaddConnectionListener in interface XMPPConnectionconnectionListener - a connection listener.public void removeConnectionListener(ConnectionListener connectionListener)
XMPPConnectionremoveConnectionListener in interface XMPPConnectionconnectionListener - a connection listener.public PacketCollector createPacketCollectorAndSend(IQ packet) throws SmackException.NotConnectedException
XMPPConnectionpacket.
 Does also send packet. The stanza(/packet) filter for the collector is an
 IQReplyFilter, guaranteeing that stanza(/packet) id and JID in the 'from' address have
 expected values.createPacketCollectorAndSend in interface XMPPConnectionpacket - the stanza(/packet) to filter responses fromSmackException.NotConnectedExceptionpublic PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet) throws SmackException.NotConnectedException
XMPPConnectionStanzaListener when you need to wait for
 a specific result.createPacketCollectorAndSend in interface XMPPConnectionpacketFilter - the stanza(/packet) filter to use.packet - the stanza(/packet) to send right after the collector got createdSmackException.NotConnectedExceptionpublic PacketCollector createPacketCollector(StanzaFilter packetFilter)
XMPPConnectionStanzaListener
 when you need to wait for a specific result.
 
 Note: If you send a Stanza(/Packet) right after using this method, then
 consider using
 XMPPConnection.createPacketCollectorAndSend(StanzaFilter, Stanza) instead.
 Otherwise make sure cancel the PacketCollector in every case, e.g. even
 if an exception is thrown, or otherwise you may leak the PacketCollector.
 
createPacketCollector in interface XMPPConnectionpacketFilter - the stanza(/packet) filter to use.public PacketCollector createPacketCollector(PacketCollector.Configuration configuration)
XMPPConnection
 Please make sure to cancel the collector when it is no longer required. See also
 XMPPConnection.createPacketCollector(StanzaFilter).
 
createPacketCollector in interface XMPPConnectionconfiguration - the stanza(/packet) collector configuration.public void removePacketCollector(PacketCollector collector)
XMPPConnectionremovePacketCollector in interface XMPPConnectioncollector - a stanza(/packet) collectors which was created for this connection.@Deprecated public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter)
XMPPConnection
 This method has been deprecated. It is important to differentiate between using an asynchronous stanza(/packet) listener
 (preferred where possible) and a synchronous stanza(/packet) lister. Refer
 XMPPConnection.addAsyncStanzaListener(StanzaListener, StanzaFilter) and
 XMPPConnection.addSyncStanzaListener(StanzaListener, StanzaFilter) for more information.
 
addPacketListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to notify of new received packets.packetFilter - the stanza(/packet) filter to use.@Deprecated public boolean removePacketListener(StanzaListener packetListener)
XMPPConnectionremovePacketListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to remove.public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter)
XMPPConnection
 Important: This stanza(/packet) listeners will be called in the same single thread that processes all
 incoming stanzas. Only use this kind of stanza(/packet) filter if it does not perform any XMPP activity that waits for a
 response. Consider using XMPPConnection.addAsyncStanzaListener(StanzaListener, StanzaFilter) when possible, i.e. when
 the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the
 arriving packets, consider using a PacketCollector when possible.
 
addSyncStanzaListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to notify of new received packets.packetFilter - the stanza(/packet) filter to use.XMPPConnection.addPacketInterceptor(StanzaListener, StanzaFilter)public boolean removeSyncStanzaListener(StanzaListener packetListener)
XMPPConnectionremoveSyncStanzaListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to remove.public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter)
XMPPConnection
 Unlike XMPPConnection.addAsyncStanzaListener(StanzaListener, StanzaFilter) stanza(/packet) listeners added with this method will be
 invoked asynchronously in their own thread. Use this method if the order of the stanza(/packet) listeners must not depend
 on the order how the stanzas where received.
 
addAsyncStanzaListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to notify of new received packets.packetFilter - the stanza(/packet) filter to use.XMPPConnection.addPacketInterceptor(StanzaListener, StanzaFilter)public boolean removeAsyncStanzaListener(StanzaListener packetListener)
XMPPConnectionremoveAsyncStanzaListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to remove.public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter)
XMPPConnectionaddPacketSendingListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to notify of sent packets.packetFilter - the stanza(/packet) filter to use.public void removePacketSendingListener(StanzaListener packetListener)
XMPPConnectionremovePacketSendingListener in interface XMPPConnectionpacketListener - the stanza(/packet) listener to remove.protected void firePacketSendingListeners(Stanza packet)
 Compared to firePacketInterceptors(Stanza), the listeners will be invoked in a new thread.
 
packet - the stanza(/packet) to process.public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter)
XMPPConnection
 NOTE: For a similar functionality on incoming packets, see XMPPConnection.addAsyncStanzaListener(StanzaListener, StanzaFilter).
addPacketInterceptor in interface XMPPConnectionpacketInterceptor - the stanza(/packet) interceptor to notify of packets about to be sent.packetFilter - the stanza(/packet) filter to use.public void removePacketInterceptor(StanzaListener packetInterceptor)
XMPPConnectionremovePacketInterceptor in interface XMPPConnectionpacketInterceptor - the stanza(/packet) interceptor to remove.protected void initDebugger()
debugger. You can specify a customized SmackDebugger
 by setup the system property smack.debuggerClass to the implementation.IllegalStateException - if the reader or writer isn't yet initialized.IllegalArgumentException - if the SmackDebugger can't be loaded.public long getPacketReplyTimeout()
XMPPConnectiongetPacketReplyTimeout in interface XMPPConnectionpublic void setPacketReplyTimeout(long timeout)
XMPPConnectionSmackException.NoResponseException if no reply to a request was received within the timeout period.setPacketReplyTimeout in interface XMPPConnectiontimeout - the stanza(/packet) reply timeout in millisecondspublic static void setReplyToUnknownIqDefault(boolean replyToUnkownIqDefault)
replyToUnkownIqDefault - setReplyToUnknownIq(boolean)public void setReplyToUnknownIq(boolean replyToUnknownIq)
XMPPError.Condition.feature_not_implemented when a request IQ without a
 registered IQRequestHandler is received.replyToUnknownIq - protected void parseAndProcessStanza(org.xmlpull.v1.XmlPullParser parser) throws Exception
Exceptionprotected void processPacket(Stanza packet) throws InterruptedException
packet - the stanza(/packet) to process.InterruptedExceptionprotected void invokePacketCollectorsAndNotifyRecvListeners(Stanza packet)
PacketCollector.processPacket(Stanza) for every
 PacketCollector with the given packet. Also notify the receive listeners with a matching stanza(/packet) filter about the packet.packet - the stanza(/packet) to notify the PacketCollectors and receive listeners about.protected void setWasAuthenticated()
wasAuthenticated flag is never reset once it has ever been set.protected void callConnectionConnectedListener()
protected void callConnectionAuthenticatedListener(boolean resumed)
protected void callConnectionClosedOnErrorListener(Exception e)
protected void notifyReconnection()
public int getConnectionCounter()
XMPPConnectiongetConnectionCounter in interface XMPPConnectionpublic void setFromMode(XMPPConnection.FromMode fromMode)
XMPPConnectionsetFromMode in interface XMPPConnectionpublic XMPPConnection.FromMode getFromMode()
XMPPConnectiongetFromMode in interface XMPPConnectionXMPPConnection.FromModeprotected final void parseFeatures(org.xmlpull.v1.XmlPullParser parser) throws org.xmlpull.v1.XmlPullParserException, IOException, SmackException
org.xmlpull.v1.XmlPullParserExceptionIOExceptionSmackExceptionprotected void afterFeaturesReceived() throws SmackException.SecurityRequiredException, SmackException.NotConnectedException
public <F extends ExtensionElement> F getFeature(String element, String namespace)
XMPPConnectionnull if the server doesn't support that feature.getFeature in interface XMPPConnectionnullpublic boolean hasFeature(String element, String namespace)
XMPPConnectionhasFeature in interface XMPPConnectionpublic void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback) throws SmackException.NotConnectedException
XMPPConnectionreplyFilter.
 
 If there is a response, then callback will be invoked. The callback will be
 invoked at most once and it will be not invoked after the connections default reply timeout
 has been elapsed.
 
sendStanzaWithResponseCallback in interface XMPPConnectionstanza - the stanza to send (required)replyFilter - the filter used to determine response stanza (required)callback - the callback invoked if there is a response (required)SmackException.NotConnectedExceptionpublic void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback, ExceptionCallback exceptionCallback) throws SmackException.NotConnectedException
XMPPConnectionreplyFilter.
 
 If there is a response, then callback will be invoked. If there is no response
 after the connections default reply timeout, then exceptionCallback will be invoked
 with a SmackException.NoResponseException. The callback will be invoked at most once.
 
sendStanzaWithResponseCallback in interface XMPPConnectionstanza - the stanza to send (required)replyFilter - the filter used to determine response stanza (required)callback - the callback invoked if there is a response (required)exceptionCallback - the callback invoked if there is an exception (optional)SmackException.NotConnectedExceptionpublic void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback, ExceptionCallback exceptionCallback, long timeout) throws SmackException.NotConnectedException
XMPPConnectionreplyFilter.
 
 If there is a response, then callback will be invoked. If there is no response
 after timeout milliseconds, then exceptionCallback will be invoked
 with a SmackException.NoResponseException. The callback will be invoked at most once.
 
sendStanzaWithResponseCallback in interface XMPPConnectionstanza - the stanza to send (required)replyFilter - the filter used to determine response stanza (required)callback - the callback invoked if there is a response (required)exceptionCallback - the callback invoked if there is an exception (optional)timeout - the timeout in milliseconds to wait for a responseSmackException.NotConnectedExceptionpublic void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws SmackException.NotConnectedException
XMPPConnectioncallback if there is a result of
 IQ.Type.result with that result IQ. The callback will
 not be invoked after the connections default reply timeout has been elapsed.sendIqWithResponseCallback in interface XMPPConnectioniqRequest - the IQ stanza to send (required)callback - the callback invoked if there is result response (required)SmackException.NotConnectedExceptionpublic void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback, ExceptionCallback exceptionCallback) throws SmackException.NotConnectedException
XMPPConnectioncallback if there is a result of
 IQ.Type.result with that result IQ. If there is an
 error response exceptionCallback will be invoked, if not null, with the received
 error as XMPPException.XMPPErrorException. If there is no response after the
 connections default reply timeout, then exceptionCallback will be invoked with a
 SmackException.NoResponseException.sendIqWithResponseCallback in interface XMPPConnectioniqRequest - the IQ stanza to send (required)callback - the callback invoked if there is result response (required)exceptionCallback - the callback invoked if there is an Exception optionalSmackException.NotConnectedExceptionpublic void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback, ExceptionCallback exceptionCallback, long timeout) throws SmackException.NotConnectedException
XMPPConnectioncallback if there is a result of
 IQ.Type.result with that result IQ. If there is an
 error response exceptionCallback will be invoked, if not null, with the received
 error as XMPPException.XMPPErrorException. If there is no response after
 timeout, then exceptionCallback will be invoked with a
 SmackException.NoResponseException.sendIqWithResponseCallback in interface XMPPConnectioniqRequest - the IQ stanza to send (required)callback - the callback invoked if there is result response (required)exceptionCallback - the callback invoked if there is an Exception optionaltimeout - the timeout in milliseconds to wait for a responseSmackException.NotConnectedExceptionpublic void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter)
XMPPConnectionaddOneTimeSyncCallback in interface XMPPConnectioncallback - the callback invoked once the stanza(/packet) filter matches a stanza.packetFilter - the filter to match stanzas or null to match all.public IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler)
XMPPConnectionIQ request handler process incoming IQ requests, i.e. incoming IQ stanzas of type 'get' or 'set', and return a result.
registerIQRequestHandler in interface XMPPConnectioniqRequestHandler - the IQ request handler to register.public final IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler)
XMPPConnectionXMPPConnection.unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type).unregisterIQRequestHandler in interface XMPPConnectionpublic IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type)
XMPPConnectionunregisterIQRequestHandler in interface XMPPConnectionelement - the IQ element the IQ request handler is responsible for.namespace - the IQ namespace the IQ request handler is responsible for.type - the IQ type the IQ request handler is responsible for.public long getLastStanzaReceived()
XMPPConnectiongetLastStanzaReceived in interface XMPPConnectionpublic void setParsingExceptionCallback(ParsingExceptionCallback callback)
callback - the callback to installpublic ParsingExceptionCallback getParsingExceptionCallback()
protected final ScheduledFuture<?> schedule(Runnable runnable, long delay, TimeUnit unit)