public final class DeliveryReceiptManager extends Manager
DeliveryReceipt
support, enabling and disabling of
automatic DeliveryReceipt transmission.
You can send delivery receipt requests and listen for incoming delivery receipts as shown in this example:
deliveryReceiptManager.addReceiptReceivedListener(new ReceiptReceivedListener() { void onReceiptReceived(String fromJid, String toJid, String receiptId, Stanza receipt) { // If the receiving entity does not support delivery receipts, // then the receipt received listener may not get invoked. } }); Message message = … DeliveryReceiptRequest.addTo(message); connection.sendStanza(message);DeliveryReceiptManager can be configured to automatically add delivery receipt requests to every message with
autoAddDeliveryReceiptRequests()
.Modifier and Type | Class and Description |
---|---|
static class |
DeliveryReceiptManager.AutoReceiptMode
Specifies when incoming message delivery receipt requests should be automatically
acknowledged with an receipt.
|
Modifier and Type | Method and Description |
---|---|
static String |
addDeliveryReceiptRequest(Message m)
Deprecated.
|
void |
addReceiptReceivedListener(ReceiptReceivedListener listener)
Get informed about incoming delivery receipts with a
ReceiptReceivedListener . |
void |
autoAddDeliveryReceiptRequests()
Enables automatic requests of delivery receipts for outgoing messages of
Message.Type.normal , Message.Type.chat or Message.Type.headline , and
with a Message.Body extension. |
void |
dontAutoAddDeliveryReceiptRequests()
Disables automatically requests of delivery receipts for outgoing messages.
|
DeliveryReceiptManager.AutoReceiptMode |
getAutoReceiptMode()
Get the currently active auto receipt mode.
|
static DeliveryReceiptManager |
getInstanceFor(XMPPConnection connection)
Obtain the DeliveryReceiptManager responsible for a connection.
|
static boolean |
hasDeliveryReceiptRequest(Message message)
Test if a message requires a delivery receipt.
|
boolean |
isSupported(Jid jid)
Returns true if Delivery Receipts are supported by a given JID.
|
static Message |
receiptMessageFor(Message messageWithReceiptRequest)
Create and return a new message including a delivery receipt extension for the given message.
|
void |
removeReceiptReceivedListener(ReceiptReceivedListener listener)
Stop getting informed about incoming delivery receipts.
|
void |
setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
Configure whether the
DeliveryReceiptManager should automatically
reply to incoming DeliveryReceipt s. |
static void |
setDefaultAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
Set the default automatic receipt mode for new connections.
|
connection, getAuthenticatedConnectionOrThrow, schedule
public static void setDefaultAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
autoReceiptMode
- the default automatic receipt mode.public static DeliveryReceiptManager getInstanceFor(XMPPConnection connection)
connection
- the connection object.public boolean isSupported(Jid jid) throws SmackException, XMPPException, InterruptedException
jid
- SmackException
- if there was no response from the server.XMPPException
InterruptedException
public void setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
DeliveryReceiptManager
should automatically
reply to incoming DeliveryReceipt
s.autoReceiptMode
- the new auto receipt mode.DeliveryReceiptManager.AutoReceiptMode
public DeliveryReceiptManager.AutoReceiptMode getAutoReceiptMode()
public void addReceiptReceivedListener(ReceiptReceivedListener listener)
ReceiptReceivedListener
.listener
- the listener to be informed about new receiptspublic void removeReceiptReceivedListener(ReceiptReceivedListener listener)
listener
- the listener to be removedpublic void autoAddDeliveryReceiptRequests()
Message.Type.normal
, Message.Type.chat
or Message.Type.headline
, and
with a Message.Body
extension.dontAutoAddDeliveryReceiptRequests()
public void dontAutoAddDeliveryReceiptRequests()
autoAddDeliveryReceiptRequests()
public static boolean hasDeliveryReceiptRequest(Message message)
message
- Stanza object to check for a DeliveryReceiptRequest@Deprecated public static String addDeliveryReceiptRequest(Message m)
DeliveryReceiptRequest.addTo(Message)
m
- Message object to add a request topublic static Message receiptMessageFor(Message messageWithReceiptRequest)
If messageWithReceiptRequest
does not have a Stanza ID set, then null
will be returned.
messageWithReceiptRequest
- the given message with a receipt request extension.null
.