Class AbstractConnection

    • Field Detail

      • closeListeners

        protected final Map<ConnectionCloseListener,​Object> closeListeners
        Contains all registered listener for close event notification. Registrations after the Session is closed will be immediately notified before the registration call returns (within the context of the registration call). An optional handback object can be associated with the registration if the same listener is registered to listen for multiple connection closures.
      • session

        protected LocalSession session
        The session that owns this connection.
    • Constructor Detail

      • AbstractConnection

        public AbstractConnection()
    • Method Detail

      • init

        public void init​(LocalSession owner)
        Description copied from interface: Connection
        Initializes the connection with it's owning session. Allows the connection class to configure itself with session related information (e.g. stream ID).
        Specified by:
        init in interface Connection
        Parameters:
        owner - the session that owns this connection
      • reinit

        public void reinit​(LocalSession owner)
        Description copied from interface: Connection
        Reinitializes the connection to switch to a different session. This allows for XEP-0198 resumption and transport-switching.
        Specified by:
        reinit in interface Connection
        Parameters:
        owner - The new session now owning the connection.
      • getSession

        public LocalSession getSession()
        Returns the session that owns this connection, if the connection has been initialized.
        Returns:
        session that owns this connection.
      • getMajorXMPPVersion

        public int getMajorXMPPVersion()
        Description copied from interface: Connection
        Returns the major version of XMPP being used by this connection (major_version.minor_version. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".
        Specified by:
        getMajorXMPPVersion in interface Connection
        Returns:
        the major XMPP version being used by this connection.
      • getMinorXMPPVersion

        public int getMinorXMPPVersion()
        Description copied from interface: Connection
        Returns the minor version of XMPP being used by this connection (major_version.minor_version. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".
        Specified by:
        getMinorXMPPVersion in interface Connection
        Returns:
        the minor XMPP version being used by this connection.
      • setXMPPVersion

        public void setXMPPVersion​(int majorVersion,
                                   int minorVersion)
        Description copied from interface: Connection
        Sets the XMPP version information. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".
        Specified by:
        setXMPPVersion in interface Connection
        Parameters:
        majorVersion - the major version.
        minorVersion - the minor version.
      • getAdditionalNamespaces

        @Nonnull
        public Set<org.dom4j.Namespace> getAdditionalNamespaces()
        Description copied from interface: Connection
        When a connection is used to transmit an XML data, the root element of that data can define XML namespaces other than the ones that are default (eg: 'jabber:client', 'jabber:server', etc). For an XML parser to be able to parse stanzas or other elements that are defined in that namespace (eg: are prefixed), these namespaces are recorded here.
        Specified by:
        getAdditionalNamespaces in interface Connection
        Returns:
        A collection that contains all non-default namespaces that the peer defined when last opening a new stream.
      • setAdditionalNamespaces

        public void setAdditionalNamespaces​(@Nonnull
                                            Set<org.dom4j.Namespace> additionalNamespaces)
        Description copied from interface: Connection
        When a connection is used to transmit an XML data, the root element of that data can define XML namespaces other than the ones that are default (eg: 'jabber:client', 'jabber:server', etc). For an XML parser to be able to parse stanzas or other elements that are defined in that namespace (eg: are prefixed), these namespaces are recorded here.
        Specified by:
        setAdditionalNamespaces in interface Connection
        Parameters:
        additionalNamespaces - A collection that contains all non-default namespaces that the peer defined when last opening a new stream.
      • registerCloseListener

        public void registerCloseListener​(ConnectionCloseListener listener,
                                          Object callback)
        Description copied from interface: Connection
        Registers a listener for close event notification. Registrations after the Session is closed will be immediately notified before the registration call returns (within the context of the registration call). An optional handback object can be associated with the registration if the same listener is registered to listen for multiple connection closures.
        Specified by:
        registerCloseListener in interface Connection
        Parameters:
        listener - the listener to register for events.
        callback - the object to send in the event notification.
      • removeCloseListener

        public void removeCloseListener​(ConnectionCloseListener listener)
        Description copied from interface: Connection
        Removes a registered close event listener. Registered listeners must be able to receive close events up until the time this method returns. (i.e. it is possible to call unregister, receive a close event registration, and then have the unregister call return.)
        Specified by:
        removeCloseListener in interface Connection
        Parameters:
        listener - the listener to deregister for close events.
      • notifyCloseListeners

        protected void notifyCloseListeners()
        Notifies all close listeners that the connection has been closed. Used by subclasses to properly finish closing the connection.