Package org.jivesoftware.smackx.receipts
Class DeliveryReceiptManager
java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.receipts.DeliveryReceiptManager
Manager for XEP-0184: Message Delivery Receipts. This class implements
the manager for
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().- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies when incoming message delivery receipt requests should be automatically acknowledged with an receipt. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringDeprecated.voidGet informed about incoming delivery receipts with aReceiptReceivedListener.voidEnables automatic requests of delivery receipts for outgoing messages ofMessage.Type.normal,Message.Type.chatorMessage.Type.headline, and with aMessage.Bodyextension.voidDisables automatically requests of delivery receipts for outgoing messages.Get the currently active auto receipt mode.static DeliveryReceiptManagergetInstanceFor(XMPPConnection connection) Obtain the DeliveryReceiptManager responsible for a connection.static booleanhasDeliveryReceiptRequest(Message message) Test if a message requires a delivery receipt.booleanisSupported(Jid jid) Returns true if Delivery Receipts are supported by a given JID.static MessagereceiptMessageFor(Message messageWithReceiptRequest) Create and return a new message including a delivery receipt extension for the given message.voidStop getting informed about incoming delivery receipts.voidsetAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode) Configure whether theDeliveryReceiptManagershould automatically reply to incomingDeliveryReceipts.static voidsetDefaultAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode) Set the default automatic receipt mode for new connections.Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
Method Details
-
setDefaultAutoReceiptMode
public static void setDefaultAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode) Set the default automatic receipt mode for new connections.- Parameters:
autoReceiptMode- the default automatic receipt mode.
-
getInstanceFor
Obtain the DeliveryReceiptManager responsible for a connection.- Parameters:
connection- the connection object.- Returns:
- the DeliveryReceiptManager instance for the given connection
-
isSupported
Returns true if Delivery Receipts are supported by a given JID.- Parameters:
jid- TODO javadoc me please- Returns:
- true if supported
- Throws:
SmackException- if there was no response from the server.XMPPException- if an XMPP protocol error was received.InterruptedException- if the calling thread was interrupted.
-
setAutoReceiptMode
Configure whether theDeliveryReceiptManagershould automatically reply to incomingDeliveryReceipts.- Parameters:
autoReceiptMode- the new auto receipt mode.- See Also:
-
getAutoReceiptMode
Get the currently active auto receipt mode.- Returns:
- the currently active auto receipt mode.
-
addReceiptReceivedListener
Get informed about incoming delivery receipts with aReceiptReceivedListener.- Parameters:
listener- the listener to be informed about new receipts
-
removeReceiptReceivedListener
Stop getting informed about incoming delivery receipts.- Parameters:
listener- the listener to be removed
-
autoAddDeliveryReceiptRequests
Enables automatic requests of delivery receipts for outgoing messages ofMessage.Type.normal,Message.Type.chatorMessage.Type.headline, and with aMessage.Bodyextension.- Since:
- 4.1
- See Also:
-
dontAutoAddDeliveryReceiptRequests
Disables automatically requests of delivery receipts for outgoing messages.- Since:
- 4.1
- See Also:
-
hasDeliveryReceiptRequest
Test if a message requires a delivery receipt.- Parameters:
message- Stanza object to check for a DeliveryReceiptRequest- Returns:
- true if a delivery receipt was requested
-
addDeliveryReceiptRequest
Deprecated.Add a delivery receipt request to an outgoing packet. Only message packets may contain receipt requests as of XEP-0184, therefore only allow Message as the parameter type.- Parameters:
m- Message object to add a request to- Returns:
- the Message ID which will be used as receipt ID
-
receiptMessageFor
Create and return a new message including a delivery receipt extension for the given message.If
messageWithReceiptRequestdoes not have a Stanza ID set, thennullwill be returned.- Parameters:
messageWithReceiptRequest- the given message with a receipt request extension.- Returns:
- a new message with a receipt or
null. - Since:
- 4.1
-
DeliveryReceiptRequest.addTo(Message)