Presence update on logout with setSendPresence(false)

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.

If I understood you correctly, then you only want Smack to send the unavailable presence on disconnect() if config.isSendPresence is true. How does this interact with LastPresence? I think I’m missing a few pieces of the whole picture.

you only want Smack to send the unavailable presence on disconnect() if config.isSendPresence is true
Yes, correctly.

Our Last Presence extension does the following: It provides the timestamp since User has sent the last Presence stanza. With default Last Activity extension we have problem with Offline messages - when app opens background connection, it affects the Last Activity. That’s why we want to rely on the Last Presence update, which is being updated based on the User actual activity (Launching the app and its usage).

I still don’t understand how not sending an unavailable presence on disconnect() interacts with your Last Presence extension.

What is your custom Last Presence extension exactly? Does it simply add a timestamp to every outgoing presence?

Did you consider using XEP-0319?

This topic was automatically closed after 2 days. New replies are no longer allowed.