Package rocks.xmpp.extensions.ping
Class PingManager
- java.lang.Object
-
- rocks.xmpp.core.session.Manager
-
- rocks.xmpp.extensions.ping.PingManager
-
- All Implemented Interfaces:
ExtensionProtocol,InboundIQHandler,InboundMessageHandler,InboundPresenceHandler,DiscoverableInfo
public final class PingManager extends Manager implements ExtensionProtocol, InboundMessageHandler, InboundPresenceHandler, InboundIQHandler, DiscoverableInfo
This class implements the application-level ping mechanism as specified in XEP-0199: XMPP Ping.If enabled, it periodically pings the server to ensure a stable connection. These pings are not sent as long as other stanzas are sent, because they serve the same purpose (telling the server, that we are still available).
For Server-To-Client Pings it automatically responds with a result (pong), if enabled.
It also allows to ping the server manually (Client-To-Server Pings) or to ping other XMPP entities (Client-to-Client Pings).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getFeatures()StringgetNamespace()DurationgetPingInterval()Gets the ping interval.voidhandleInboundIQ(IQEvent e)voidhandleInboundMessage(MessageEvent e)voidhandleInboundPresence(PresenceEvent e)AsyncResult<Boolean>ping(Jid jid)Pings the given XMPP entity.AsyncResult<Boolean>pingServer()Pings the connected server.voidsetPingInterval(Duration pingInterval)Sets the automatic ping interval.-
Methods inherited from class rocks.xmpp.core.session.Manager
isEnabled, setEnabled
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rocks.xmpp.extensions.disco.model.info.DiscoverableInfo
getExtensions, getIdentities
-
Methods inherited from interface rocks.xmpp.core.ExtensionProtocol
isEnabled
-
-
-
-
Method Detail
-
ping
public final AsyncResult<Boolean> ping(Jid jid)
Pings the given XMPP entity.- Parameters:
jid- The JID to ping.- Returns:
- The async result with true if a response has been received within the timeout and the recipient is available, false otherwise.
-
pingServer
public final AsyncResult<Boolean> pingServer()
Pings the connected server.- Returns:
- The async result with true if a response has been received, false otherwise.
-
getPingInterval
public final Duration getPingInterval()
Gets the ping interval. The default ping interval is 900 seconds (15 minutes).- Returns:
- The ping interval in seconds.
- See Also:
setPingInterval(Duration)
-
setPingInterval
public final void setPingInterval(Duration pingInterval)
Sets the automatic ping interval. Any scheduled future ping is canceled and a new ping is scheduled after the specified interval.- Parameters:
pingInterval- The ping interval in seconds.- See Also:
getPingInterval()
-
getNamespace
public final String getNamespace()
- Specified by:
getNamespacein interfaceExtensionProtocol
-
getFeatures
public final Set<String> getFeatures()
- Specified by:
getFeaturesin interfaceDiscoverableInfo
-
handleInboundIQ
public final void handleInboundIQ(IQEvent e)
- Specified by:
handleInboundIQin interfaceInboundIQHandler
-
handleInboundMessage
public final void handleInboundMessage(MessageEvent e)
- Specified by:
handleInboundMessagein interfaceInboundMessageHandler
-
handleInboundPresence
public final void handleInboundPresence(PresenceEvent e)
- Specified by:
handleInboundPresencein interfaceInboundPresenceHandler
-
-