AnsweredAssumed Answered

Presence update on logout with setSendPresence(false)

Question asked by Dmitry on Jul 6, 2017
Latest reply on Jul 19, 2017 by Flow

Hello,

In our project we use "Offline Message Retrieval" and  custom "Last Presence" extensions.

For the offline messages we open a connection with builder.setSendPresence(false);

Because of the following code in AbstractXMPPConnection:

if (config.isSendPresence() && !resumed) {

  sendStanza(new Presence(Presence.Type.available));
}

The presence is not being sent, which is correct.

But later, when we disconnect, in the

public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {

   try {

  sendStanza(unavailablePresence);
   }

The presence stanza is being sent regardless the setSendPresence(false). This is causing the problem that the Last Presence extension is not working correctly.

So, our suggestion is to change the disconnect method to:

public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException {

if (config.isSendPresence()) {

   try {

  sendStanza(unavailablePresence);
   }

   catch (InterruptedException e) {

   LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", e);
   }

}

Do you have any objections? Or can we apply the changes above to the code?

Dmitry.

Outcomes