mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +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() {
|
public void disconnect() {
|
||||||
|
Presence unavailablePresence = null;
|
||||||
|
if (isAuthenticated()) {
|
||||||
|
unavailablePresence = new Presence(Presence.Type.unavailable);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
disconnect(new Presence(Presence.Type.unavailable));
|
disconnect(unavailablePresence);
|
||||||
}
|
}
|
||||||
catch (NotConnectedException e) {
|
catch (NotConnectedException e) {
|
||||||
LOGGER.log(Level.FINEST, "Connection is already disconnected", 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
|
* stanza(/packet) is set with online information, but most XMPP servers will deliver the full
|
||||||
* presence stanza(/packet) with whatever data is set.
|
* 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
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
|
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {
|
||||||
try {
|
if (unavailablePresence != null) {
|
||||||
sendStanza(unavailablePresence);
|
try {
|
||||||
}
|
sendStanza(unavailablePresence);
|
||||||
catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", e);
|
LOGGER.log(Level.FINE,
|
||||||
|
"Was interrupted while sending unavailable presence. Continuing to disconnect the connection",
|
||||||
|
e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shutdown();
|
shutdown();
|
||||||
callConnectionClosedListener();
|
callConnectionClosedListener();
|
||||||
|
|
Loading…
Reference in a new issue