Package org.jivesoftware.smackx.geoloc
Class GeoLocationManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.geoloc.GeoLocationManager
-
public final class GeoLocationManager extends Manager
Entry point for Smacks API for XEP-0080: User Location.
To publish a UserLocation, please usepublishGeoLocation(GeoLocation)
method. This will publish the node.
To stop publishing a UserLocation, please usestopPublishingGeolocation()
method. This will send a disble publishing signal.
To add aPepEventListener
in order to remain updated with other users GeoLocation, useaddGeoLocationListener(PepEventListener)
method.
To link a GeoLocation withMessage
, use `message.addExtension(geoLocation)`.
An example for illustration is provided inside GeoLocationTest inside the test package.- See Also:
- XEP-0080: User Location
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
GEOLOCATION_NODE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addGeoLocationListener(PepEventListener<GeoLocation> listener)
static GeoLocationManager
getInstanceFor(XMPPConnection connection)
Retrieves aGeoLocationManager
for the specifiedXMPPConnection
, creating one if it doesn't already exist.static boolean
isGeoLocationMessage(Message message)
Returns true if the message contains a GeoLocation extension.void
publishGeoLocation(GeoLocation geoLocation)
Publish the user's geographic location through the Personal Eventing Protocol (PEP).boolean
removeGeoLocationListener(PepEventListener<GeoLocation> listener)
void
sendGeoLocationToJid(GeoLocation geoLocation, Jid jid)
void
stopPublishingGeolocation()
Send empty geolocation through the PubSub node.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
GEOLOCATION_NODE
public static final java.lang.String GEOLOCATION_NODE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstanceFor
public static GeoLocationManager getInstanceFor(XMPPConnection connection)
Retrieves aGeoLocationManager
for the specifiedXMPPConnection
, 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, Jid jid) throws java.lang.InterruptedException, SmackException.NotConnectedException
- Throws:
java.lang.InterruptedException
SmackException.NotConnectedException
-
isGeoLocationMessage
public static boolean isGeoLocationMessage(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 SmackException.NoResponseException, XMPPException.XMPPErrorException, 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.SmackException.NotConnectedException
- if the XMPP connection is not connected.XMPPException.XMPPErrorException
- if there was an XMPP error returned.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 SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException, PubSubException.NotALeafNodeException
Send empty geolocation through the PubSub node.- Throws:
java.lang.InterruptedException
- if the calling thread was interrupted.SmackException.NotConnectedException
- if the XMPP connection is not connected.XMPPException.XMPPErrorException
- if there was an XMPP error returned.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)
-
-