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.String
getNamespace()
The protocol's main namespace.Duration
getPingInterval()
Gets the ping interval.void
handleInboundIQ(IQEvent e)
Handles an inbound IQ.void
handleInboundMessage(MessageEvent e)
Handles an inbound message.void
handleInboundPresence(PresenceEvent e)
Handles an inbound presence.AsyncResult<Boolean>
ping(Jid jid)
Pings the given XMPP entity.AsyncResult<Boolean>
pingServer()
Pings the connected server.void
setPingInterval(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:ExtensionProtocol
The protocol's main namespace. This is used to uniquely identify the extension protocol.- Specified by:
getNamespace
in interfaceExtensionProtocol
- Returns:
- The main namespace.
-
getFeatures
public final Set<String> getFeatures()
Description copied from interface:DiscoverableInfo
Gets the features.- Specified by:
getFeatures
in interfaceDiscoverableInfo
- Returns:
- The features.
-
handleInboundIQ
public final void handleInboundIQ(IQEvent e)
Description copied from interface:InboundIQHandler
Handles an inbound IQ.- Specified by:
handleInboundIQ
in interfaceInboundIQHandler
- Parameters:
e
- The IQ event.
-
handleInboundMessage
public final void handleInboundMessage(MessageEvent e)
Description copied from interface:InboundMessageHandler
Handles an inbound message.- Specified by:
handleInboundMessage
in interfaceInboundMessageHandler
- Parameters:
e
- The message event.
-
handleInboundPresence
public final void handleInboundPresence(PresenceEvent e)
Description copied from interface:InboundPresenceHandler
Handles an inbound presence.- Specified by:
handleInboundPresence
in interfaceInboundPresenceHandler
- Parameters:
e
- The presence event.
-
-