Class AbstractXMPPConnection

java.lang.Object
org.jivesoftware.smack.AbstractXMPPConnection
All Implemented Interfaces:
XMPPConnection
Direct Known Subclasses:
ModularXmppClientToServerConnection

public abstract class AbstractXMPPConnection extends Object implements XMPPConnection
This abstract class is commonly used as super class for XMPP connection mechanisms like TCP and BOSH. Hence, it provides the methods for connection state management, like connect(), login() and disconnect() (which are deliberately not provided by the XMPPConnection interface).

Note: The default entry point to Smack's documentation is XMPPConnection. If you are getting started with Smack, then head over to XMPPConnection and the come back here.

Parsing Exceptions

In case a Smack parser (Provider) throws those exceptions are handled over to the ParsingExceptionCallback. A common cause for a provider throwing is illegal input, for example a non-numeric String where only Integers are allowed. Smack's default behavior is to take the stanza out of the stream in this case, i.e., Smack behaves like that stream element was never received.

If the parsing exception is because Smack received illegal input, then please consider informing the authors of the originating entity about that. If it was thrown because of an bug in a Smack parser, then please consider filling a bug with Smack.

Managing the parsing exception callback

You can change the behavior using setParsingExceptionCallback(ParsingExceptionCallback) to set a custom callback. Use SmackConfiguration.setDefaultParsingExceptionCallback(ParsingExceptionCallback) to set the default callback.

  • Field Details

    • SMACK_REACTOR

      protected static final SmackReactor SMACK_REACTOR
    • connectionListeners

      protected final Set<ConnectionListener> connectionListeners
      A collection of ConnectionListeners which listen for connection closing and reconnection events.
    • outgoingStreamXmlEnvironment

      protected XmlEnvironment outgoingStreamXmlEnvironment
    • connectionLock

      protected final Lock connectionLock
    • streamFeatures

      protected final Map<QName,XmlElement> streamFeatures
    • user

      protected org.jxmpp.jid.EntityFullJid user
      The full JID of the authenticated user, as returned by the resource binding response of the server.

      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.

    • connected

      protected boolean connected
    • streamId

      protected String streamId
      The stream ID, see RFC 6120 § 4.7.3
    • debugger

      protected final SmackDebugger debugger
      The SmackDebugger allows to log and debug XML traffic.
    • reader

      protected Reader reader
      The Reader which is used for the debugger.
    • writer

      protected Writer writer
      The Writer which is used for the debugger.
    • tlsHandled

      protected boolean tlsHandled
    • lastFeaturesReceived

      protected boolean lastFeaturesReceived
      Set to true if the last features stanza from the server has been parsed. A XMPP connection handshake can invoke multiple features stanzas, e.g. when TLS is activated a second feature stanza is send by the server. This is set to true once the last feature stanza has been parsed.
    • saslFeatureReceived

      protected boolean saslFeatureReceived
      Set to true if the SASL feature has been received.
    • closingStreamReceived

      protected boolean closingStreamReceived
      A synchronization point which is successful if this connection has received the closing stream element from the remote end-point, i.e. the server.
    • connectionCounterValue

      protected final int connectionCounterValue
      A number to uniquely identify connections that are created. This is distinct from the connection ID, which is a value sent by the server once a connection is made.
    • config

      protected final ConnectionConfiguration config
      Holds the initial configuration used while creating the connection.
    • compressionHandler

      protected XMPPInputOutputStream compressionHandler
    • ASYNC_BUT_ORDERED

      protected static final AsyncButOrdered<AbstractXMPPConnection> ASYNC_BUT_ORDERED
    • host

      protected String host
      The used host to establish the connection to
    • port

      protected UInt16 port
      The used port to establish the connection to
    • authenticated

      protected boolean authenticated
      Flag that indicates if the user is currently authenticated with the server.
    • authenticatedConnectionInitiallyEstablishedTimestamp

      protected ZonedDateTime authenticatedConnectionInitiallyEstablishedTimestamp
    • wasAuthenticated

      protected boolean wasAuthenticated
      Flag that indicates if the user was authenticated with the server when the connection to the server was closed (abruptly or not).
  • Constructor Details

    • AbstractXMPPConnection

      protected AbstractXMPPConnection(ConnectionConfiguration configuration)
      Create a new XMPPConnection to an XMPP server.
      Parameters:
      configuration - The configuration which is used to establish the connection.
  • Method Details