mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Do not send unavailable on disconnect() when not authenticated
This commit is contained in:
parent
1bd3469fec
commit
5e25491877
1 changed files with 14 additions and 7 deletions
|
@ -706,8 +706,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
*
|
||||
*/
|
||||
public void disconnect() {
|
||||
Presence unavailablePresence = null;
|
||||
if (isAuthenticated()) {
|
||||
unavailablePresence = new Presence(Presence.Type.unavailable);
|
||||
}
|
||||
try {
|
||||
disconnect(new Presence(Presence.Type.unavailable));
|
||||
disconnect(unavailablePresence);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
LOGGER.log(Level.FINEST, "Connection is already disconnected", e);
|
||||
|
@ -722,15 +726,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* stanza(/packet) is set with online information, but most XMPP servers will deliver the full
|
||||
* presence stanza(/packet) with whatever data is set.
|
||||
*
|
||||
* @param unavailablePresence the presence stanza(/packet) to send during shutdown.
|
||||
* @param unavailablePresence the optional presence stanza to send during shutdown.
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
|
||||
try {
|
||||
sendStanza(unavailablePresence);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", e);
|
||||
if (unavailablePresence != null) {
|
||||
try {
|
||||
sendStanza(unavailablePresence);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.log(Level.FINE,
|
||||
"Was interrupted while sending unavailable presence. Continuing to disconnect the connection",
|
||||
e);
|
||||
}
|
||||
}
|
||||
shutdown();
|
||||
callConnectionClosedListener();
|
||||
|
|
Loading…
Reference in a new issue