Smack

org.jivesoftware.smackx.ping
Class PingManager

java.lang.Object
  extended by org.jivesoftware.smackx.ping.PingManager

public class PingManager
extends java.lang.Object

Implements the XMPP Ping as defined by XEP-0199. The XMPP Ping protocol allows one entity to 'ping' any other entity by simply sending a ping to the appropriate JID.

NOTE: The KeepAliveManager already provides a keepalive functionality for regularly pinging the server to keep the underlying transport connection alive. This class is specifically intended to do manual pings of other entities.

Author:
Florian Schmaus
See Also:
XEP-0199:XMPP Ping

Method Summary
static PingManager getInstanceFor(Connection connection)
          Retrieves a PingManager for the specified Connection, creating one if it doesn't already exist.
 boolean isPingSupported(java.lang.String jid)
          Query the specified entity to see if it supports the Ping protocol (XEP-0199)
 boolean ping(java.lang.String jid)
          Same as calling ping(String, long) with the defaultpacket reply timeout.
 boolean ping(java.lang.String jid, long pingTimeout)
          Pings the given jid.
 boolean pingMyServer()
          Pings the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceFor

public static PingManager getInstanceFor(Connection connection)
Retrieves a PingManager for the specified Connection, creating one if it doesn't already exist.

Parameters:
connection - The connection the manager is attached to.
Returns:
The new or existing manager.

ping

public boolean ping(java.lang.String jid,
                    long pingTimeout)
Pings the given jid. This method will return false if an error occurs. The exception to this, is a server ping, which will always return true if the server is reachable, event if there is an error on the ping itself (i.e. ping not supported).

Use isPingSupported(String) to determine if XMPP Ping is supported by the entity.

Parameters:
jid - The id of the entity the ping is being sent to
pingTimeout - The time to wait for a reply
Returns:
true if a reply was received from the entity, false otherwise.

ping

public boolean ping(java.lang.String jid)
Same as calling ping(String, long) with the defaultpacket reply timeout.

Parameters:
jid - The id of the entity the ping is being sent to
Returns:
true if a reply was received from the entity, false otherwise.

isPingSupported

public boolean isPingSupported(java.lang.String jid)
                        throws XMPPException
Query the specified entity to see if it supports the Ping protocol (XEP-0199)

Parameters:
jid - The id of the entity the query is being sent to
Returns:
true if it supports ping, false otherwise.
Throws:
XMPPException - An XMPP related error occurred during the request

pingMyServer

public boolean pingMyServer()
Pings the server. This method will return true if the server is reachable. It is the equivalent of calling ping with the XMPP domain.

Unlike the ping(String) case, this method will return true even if isPingSupported(String) is false.

Returns:
true if a reply was received from the server, false otherwise.

Smack

Copyright © 2003-2007 Jive Software.