1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-08 14:11:07 +01:00

Cleanup of pingMyServer() API

only throw NotConnectedException, otherwise return false. Before as
some sort of exception was always thrown in the error case.
This commit is contained in:
Florian Schmaus 2014-03-28 14:27:14 +01:00
parent 17a254edca
commit 665d65836c
2 changed files with 21 additions and 17 deletions

View file

@ -183,9 +183,10 @@ public class PingManager extends Manager {
*
* @param jid The id of the entity the ping is being sent to
* @return true if a reply was received from the entity, false otherwise.
* @throws SmackException if there was no response from the server.
* @throws NotConnectedException
* @throws NoResponseException
*/
public boolean ping(String jid) throws SmackException {
public boolean ping(String jid) throws NoResponseException, NotConnectedException {
return ping(jid, connection().getPacketReplyTimeout());
}
@ -210,9 +211,9 @@ public class PingManager extends Manager {
* {@link #isPingSupported(String)} is false.
*
* @return true if a reply was received from the server, false otherwise.
* @throws SmackException if there was no response from the server.
* @throws NotConnectedException
*/
public boolean pingMyServer() throws SmackException {
public boolean pingMyServer() throws NotConnectedException {
return pingMyServer(true);
}
@ -225,13 +226,21 @@ public class PingManager extends Manager {
*
* @param notifyListeners Notify the PingFailedListener in case of error if true
* @return true if the user's server could be pinged.
* @throws SmackException if there was no response from the server.
* @throws NotConnectedException
*/
public boolean pingMyServer(boolean notifyListeners) throws SmackException {
boolean res = ping(connection().getServiceName());
public boolean pingMyServer(boolean notifyListeners) throws NotConnectedException {
boolean res;
try {
res = ping(connection().getServiceName());
}
catch (NoResponseException e) {
res = false;
}
if (res) {
pongReceived();
} else if (notifyListeners) {
}
else if (notifyListeners) {
for (PingFailedListener l : pingFailedListeners)
l.pingFailed();
}