Class GeoLocationManager

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.geoloc.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 disable 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:
  • Field Details

  • Method Details

    • 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 InterruptedException, org.jivesoftware.smack.SmackException.NotConnectedException
      Throws:
      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, InterruptedException, PubSubException.NotALeafNodeException
      Publish the user's geographic location through the Personal Eventing Protocol (PEP).
      Parameters:
      geoLocation - the geographic location to publish.
      Throws:
      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, InterruptedException, PubSubException.NotALeafNodeException
      Send empty geolocation through the PubSub node.
      Throws:
      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.
    • addGeoLocationListener

      public boolean addGeoLocationListener(PepEventListener<GeoLocation> listener)
    • removeGeoLocationListener

      public boolean removeGeoLocationListener(PepEventListener<GeoLocation> listener)