Class GeoLocationManager


  • public final class GeoLocationManager
    extends org.jivesoftware.smack.Manager
    Entry point for Smacks API for XEP-0080: User Location.
    To publish a UserLocation, please use publishGeoLocation(GeoLocation) method. This will publish the node.
    To stop publishing a UserLocation, please use stopPublishingGeolocation() method. This will send a disble publishing signal.
    To add a PepEventListener in order to remain updated with other users GeoLocation, use addGeoLocationListener(PepEventListener) method.
    To link a GeoLocation with Message, use `message.addExtension(geoLocation)`.
    An example for illustration is provided inside GeoLocationTest inside the test package.
    See Also:
    XEP-0080: User Location
    • Field Detail

      • GEOLOCATION_NODE

        public static final java.lang.String GEOLOCATION_NODE
        See Also:
        Constant Field Values
    • Method Detail

      • getInstanceFor

        public static GeoLocationManager getInstanceFor​(org.jivesoftware.smack.XMPPConnection connection)
        Retrieves a GeoLocationManager for the specified XMPPConnection, creating one if it doesn't already exist.
        Parameters:
        connection - The connection the manager is attached to.
        Returns:
        The new or existing manager.
      • sendGeoLocationToJid

        public void sendGeoLocationToJid​(GeoLocation geoLocation,
                                         org.jxmpp.jid.Jid jid)
                                  throws java.lang.InterruptedException,
                                         org.jivesoftware.smack.SmackException.NotConnectedException
        Throws:
        java.lang.InterruptedException
        org.jivesoftware.smack.SmackException.NotConnectedException
      • isGeoLocationMessage

        public static boolean isGeoLocationMessage​(org.jivesoftware.smack.packet.Message message)
        Returns true if the message contains a GeoLocation extension.
        Parameters:
        message - the message to check if contains a GeoLocation extension or not
        Returns:
        a boolean indicating whether the message is a GeoLocation message
      • publishGeoLocation

        public void publishGeoLocation​(GeoLocation geoLocation)
                                throws org.jivesoftware.smack.SmackException.NoResponseException,
                                       org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                       org.jivesoftware.smack.SmackException.NotConnectedException,
                                       java.lang.InterruptedException,
                                       PubSubException.NotALeafNodeException
        Publish the user's geographic location through the Personal Eventing Protocol (PEP).
        Parameters:
        geoLocation - the geographic location to publish.
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.
      • stopPublishingGeolocation

        public void stopPublishingGeolocation()
                                       throws org.jivesoftware.smack.SmackException.NoResponseException,
                                              org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                              org.jivesoftware.smack.SmackException.NotConnectedException,
                                              java.lang.InterruptedException,
                                              PubSubException.NotALeafNodeException
        Send empty geolocation through the PubSub node.
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        PubSubException.NotALeafNodeException - if a PubSub leaf node operation was attempted on a non-leaf node.