1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +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 * the XMPP server. The XMPPConnection can still be used for connecting to the server
* again. * again.
* *
* @throws NotConnectedException
*/ */
public void disconnect() throws NotConnectedException { public void disconnect() {
disconnect(new Presence(Presence.Type.unavailable)); 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 * @throws NotConnectedException
*/ */
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException { public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
if (!isConnected()) {
throw new NotConnectedException();
}
sendPacket(unavailablePresence); sendPacket(unavailablePresence);
shutdown(); shutdown();
callConnectionClosedListener(); callConnectionClosedListener();