mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Fix DeliveryReceiptsManager.autoAddDeliveryReceiptRequests
Must use interceptors instead of sending listeners, as those are invoked *after* the stanza has been put on the wire. Also use the correct filter, which excludes ack messages. Fixes SMACK-656.
This commit is contained in:
parent
062e9ee415
commit
475fed8c51
1 changed files with 14 additions and 3 deletions
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
|
@ -232,6 +233,16 @@ public class DeliveryReceiptManager extends Manager {
|
|||
receiptReceivedListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* A filter for stanzas to request delivery receipts for. Notably those are message stanzas of type normal, chat or
|
||||
* headline, which <b>do not</b>contain a delivery receipt, i.e. are ack messages.
|
||||
*
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0184.html#when-ack">XEP-184 § 5.4 Ack Messages</a>
|
||||
*/
|
||||
private static final StanzaFilter MESSAGES_TO_REQUEST_RECEIPTS_FOR = new AndFilter(
|
||||
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, new NotFilter(new StanzaExtensionFilter(
|
||||
DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)));
|
||||
|
||||
private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
|
@ -247,8 +258,8 @@ public class DeliveryReceiptManager extends Manager {
|
|||
* @see #dontAutoAddDeliveryReceiptRequests()
|
||||
*/
|
||||
public void autoAddDeliveryReceiptRequests() {
|
||||
connection().addPacketSendingListener(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
|
||||
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE);
|
||||
connection().addPacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
|
||||
MESSAGES_TO_REQUEST_RECEIPTS_FOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +269,7 @@ public class DeliveryReceiptManager extends Manager {
|
|||
* @see #autoAddDeliveryReceiptRequests()
|
||||
*/
|
||||
public void dontAutoAddDeliveryReceiptRequests() {
|
||||
connection().removePacketSendingListener(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
|
||||
connection().removePacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue