1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 12:37:58 +01:00

Make disconnect() not throw NotConnectedException

while disconnect(Presence) still does to notify the user that the
unavailable presence was not send.
This commit is contained in:
Florian Schmaus 2015-01-13 23:09:43 +01:00
parent eb6b8df7c5
commit fc14962445

View file

@ -643,10 +643,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* the XMPP server. The XMPPConnection can still be used for connecting to the server
* again.
*
* @throws NotConnectedException
*/
public void disconnect() throws NotConnectedException {
disconnect(new Presence(Presence.Type.unavailable));
public void disconnect() {
try {
disconnect(new Presence(Presence.Type.unavailable));
}
catch (NotConnectedException e) {
LOGGER.log(Level.FINEST, "Connection is already disconnected", e);
}
}
/**
@ -661,10 +665,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws NotConnectedException
*/
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
if (!isConnected()) {
throw new NotConnectedException();
}
sendPacket(unavailablePresence);
shutdown();
callConnectionClosedListener();