public class PingManager extends Manager
Modifier and Type | Method and Description |
---|---|
static PingManager |
getInstanceFor(XMPPConnection connection)
Retrieves a
PingManager for the specified XMPPConnection , creating one if it doesn't already
exist. |
long |
getLastReceivedPong()
Returns the timestamp when the last XMPP Pong was received.
|
int |
getPingInterval()
Get the current ping interval.
|
boolean |
isPingSupported(String jid)
Query the specified entity to see if it supports the Ping protocol (XEP-0199)
|
boolean |
ping(String jid)
Same as calling
ping(String, long) with the defaultpacket reply
timeout. |
boolean |
ping(String jid,
long pingTimeout)
Pings the given jid.
|
boolean |
pingMyServer()
Pings the server.
|
boolean |
pingMyServer(boolean notifyListeners)
Pings the server.
|
void |
registerPingFailedListener(PingFailedListener listener)
Register a new PingFailedListener
|
static void |
setDefaultPingInterval(int interval)
Set the default ping interval which will be used for new connections.
|
void |
setPingInterval(int pingInterval)
Set the interval between the server is automatic pinged.
|
void |
unregisterPingFailedListener(PingFailedListener listener)
Unregister a PingFailedListener
|
connection, schedule
public static final String NAMESPACE
public static PingManager getInstanceFor(XMPPConnection connection)
PingManager
for the specified XMPPConnection
, creating one if it doesn't already
exist.connection
- The connection the manager is attached to.public static void setDefaultPingInterval(int interval)
interval
- the interval in secondspublic boolean ping(String jid, long pingTimeout) throws SmackException.NotConnectedException, SmackException.NoResponseException
Use isPingSupported(String)
to determine if XMPP Ping is supported
by the entity.
jid
- The id of the entity the ping is being sent topingTimeout
- The time to wait for a replySmackException.NoResponseException
- if there was no response from the jid.SmackException.NotConnectedException
public boolean ping(String jid) throws SmackException.NotConnectedException, SmackException.NoResponseException
ping(String, long)
with the defaultpacket reply
timeout.jid
- The id of the entity the ping is being sent toSmackException.NotConnectedException
SmackException.NoResponseException
- if there was no response from the jid.public boolean isPingSupported(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
jid
- The id of the entity the query is being sent toXMPPException.XMPPErrorException
- An XMPP related error occurred during the requestSmackException.NoResponseException
- if there was no response from the jid.SmackException.NotConnectedException
public boolean pingMyServer() throws SmackException.NotConnectedException
ping
with the XMPP domain.
Unlike the ping(String)
case, this method will return true even if
isPingSupported(String)
is false.
SmackException.NotConnectedException
public boolean pingMyServer(boolean notifyListeners) throws SmackException.NotConnectedException
ping
with the XMPP domain.
Unlike the ping(String)
case, this method will return true even if
isPingSupported(String)
is false.
notifyListeners
- Notify the PingFailedListener in case of error if trueSmackException.NotConnectedException
public void setPingInterval(int pingInterval)
pingInterval
- the interval between the pingpublic int getPingInterval()
public void registerPingFailedListener(PingFailedListener listener)
listener
- the listener to invokepublic void unregisterPingFailedListener(PingFailedListener listener)
listener
- the listener to removepublic long getLastReceivedPong()