From 414db1ebbed299ee8d0e20a722b93473f6df6bd5 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 30 Sep 2014 13:09:09 +0200 Subject: [PATCH] Add PingManager.pingMyServer(boolean,long) --- .../jivesoftware/smackx/ping/PingManager.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java index 8bcc98d6d..2e4f5573f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java @@ -245,9 +245,25 @@ public class PingManager extends Manager { * @throws NotConnectedException */ public boolean pingMyServer(boolean notifyListeners) throws NotConnectedException { + return pingMyServer(notifyListeners, connection().getPacketReplyTimeout()); + } + + /** + * 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 {@link #ping(String)} case, this method will return true even if + * {@link #isPingSupported(String)} is false. + * + * @param notifyListeners Notify the PingFailedListener in case of error if true + * @param pingTimeout The time to wait for a reply in milliseconds + * @return true if the user's server could be pinged. + * @throws NotConnectedException + */ + public boolean pingMyServer(boolean notifyListeners, long pingTimeout) throws NotConnectedException { boolean res; try { - res = ping(connection().getServiceName()); + res = ping(connection().getServiceName(), pingTimeout); } catch (NoResponseException e) { res = false;