Class AbstractXMPPConnection

  • All Implemented Interfaces:
    Direct Known Subclasses:
    ModularXmppClientToServerConnection, XMPPBOSHConnection, XMPPTCPConnection

    public abstract class AbstractXMPPConnection
    extends java.lang.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 follows the "fail-hard per default" principle leading to a termination of the connection on parsing exceptions. This default was chosen to make users eventually aware that they should configure their own callback and handle those exceptions to prevent the disconnect. Handle a parsing exception could be as simple as using a non-throwing no-op callback, which would cause the faulty stream element to be taken out of the stream, i.e., Smack behaves like that 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

    The "fail-hard per default" behavior is achieved by using the ExceptionThrowingCallbackWithHint as default parsing exception callback. You can change the behavior using setParsingExceptionCallback(ParsingExceptionCallback) to set a new callback. Use SmackConfiguration.setDefaultParsingExceptionCallback(ParsingExceptionCallback) to set the default callback.