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()Gets the features.StringgetNamespace()The protocol's main namespace.DurationgetPingInterval()Gets the ping interval.voidhandleInboundIQ(IQEvent e)Handles an inbound IQ.voidhandleInboundMessage(MessageEvent e)Handles an inbound message.voidhandleInboundPresence(PresenceEvent e)Handles an inbound presence.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()
Description copied from interface:ExtensionProtocolThe protocol's main namespace. This is used to uniquely identify the extension protocol.- Specified by:
getNamespacein interfaceExtensionProtocol- Returns:
- The main namespace.
-
getFeatures
public final Set<String> getFeatures()
Description copied from interface:DiscoverableInfoGets the features.- Specified by:
getFeaturesin interfaceDiscoverableInfo- Returns:
- The features.
-
handleInboundIQ
public final void handleInboundIQ(IQEvent e)
Description copied from interface:InboundIQHandlerHandles an inbound IQ.- Specified by:
handleInboundIQin interfaceInboundIQHandler- Parameters:
e- The IQ event.
-
handleInboundMessage
public final void handleInboundMessage(MessageEvent e)
Description copied from interface:InboundMessageHandlerHandles an inbound message.- Specified by:
handleInboundMessagein interfaceInboundMessageHandler- Parameters:
e- The message event.
-
handleInboundPresence
public final void handleInboundPresence(PresenceEvent e)
Description copied from interface:InboundPresenceHandlerHandles an inbound presence.- Specified by:
handleInboundPresencein interfaceInboundPresenceHandler- Parameters:
e- The presence event.
-
-