Package org.jivesoftware.smackx.receipts
Class DeliveryReceiptManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.receipts.DeliveryReceiptManager
-
public final class DeliveryReceiptManager extends Manager
Manager for XEP-0184: Message Delivery Receipts. This class implements the manager forDeliveryReceiptsupport, 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 withautoAddDeliveryReceiptRequests().- See Also:
- XEP-0184: Message Delivery Receipts
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeliveryReceiptManager.AutoReceiptModeSpecifies when incoming message delivery receipt requests should be automatically acknowledged with an receipt.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.StringaddDeliveryReceiptRequest(Message m)Deprecated.voidaddReceiptReceivedListener(ReceiptReceivedListener listener)Get informed about incoming delivery receipts with aReceiptReceivedListener.voidautoAddDeliveryReceiptRequests()Enables automatic requests of delivery receipts for outgoing messages ofMessage.Type.normal,Message.Type.chatorMessage.Type.headline, and with aMessage.Bodyextension.voiddontAutoAddDeliveryReceiptRequests()Disables automatically requests of delivery receipts for outgoing messages.DeliveryReceiptManager.AutoReceiptModegetAutoReceiptMode()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.voidremoveReceiptReceivedListener(ReceiptReceivedListener listener)Stop 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 Detail
-
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
public static DeliveryReceiptManager getInstanceFor(XMPPConnection connection)
Obtain the DeliveryReceiptManager responsible for a connection.- Parameters:
connection- the connection object.- Returns:
- the DeliveryReceiptManager instance for the given connection
-
isSupported
public boolean isSupported(Jid jid) throws SmackException, XMPPException, java.lang.InterruptedException
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.java.lang.InterruptedException- if the calling thread was interrupted.
-
setAutoReceiptMode
public void setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
Configure whether theDeliveryReceiptManagershould automatically reply to incomingDeliveryReceipts.- Parameters:
autoReceiptMode- the new auto receipt mode.- See Also:
DeliveryReceiptManager.AutoReceiptMode
-
getAutoReceiptMode
public DeliveryReceiptManager.AutoReceiptMode getAutoReceiptMode()
Get the currently active auto receipt mode.- Returns:
- the currently active auto receipt mode.
-
addReceiptReceivedListener
public void addReceiptReceivedListener(ReceiptReceivedListener listener)
Get informed about incoming delivery receipts with aReceiptReceivedListener.- Parameters:
listener- the listener to be informed about new receipts
-
removeReceiptReceivedListener
public void removeReceiptReceivedListener(ReceiptReceivedListener listener)
Stop getting informed about incoming delivery receipts.- Parameters:
listener- the listener to be removed
-
autoAddDeliveryReceiptRequests
public void 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()
-
dontAutoAddDeliveryReceiptRequests
public void dontAutoAddDeliveryReceiptRequests()
Disables automatically requests of delivery receipts for outgoing messages.- Since:
- 4.1
- See Also:
autoAddDeliveryReceiptRequests()
-
hasDeliveryReceiptRequest
public static boolean hasDeliveryReceiptRequest(Message message)
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 public static java.lang.String addDeliveryReceiptRequest(Message m)
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
public static Message receiptMessageFor(Message messageWithReceiptRequest)
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
-
-