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 forDeliveryReceipt
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 withautoAddDeliveryReceiptRequests()
.- See Also:
- XEP-0184: Message Delivery Receipts
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeliveryReceiptManager.AutoReceiptMode
Specifies 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 String
addDeliveryReceiptRequest(Message m)
Deprecated.void
addReceiptReceivedListener(ReceiptReceivedListener listener)
Get informed about incoming delivery receipts with aReceiptReceivedListener
.void
autoAddDeliveryReceiptRequests()
Enables automatic requests of delivery receipts for outgoing messages ofMessage.Type.normal
,Message.Type.chat
orMessage.Type.headline
, and with aMessage.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 theDeliveryReceiptManager
should automatically reply to incomingDeliveryReceipt
s.static void
setDefaultAutoReceiptMode(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, 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.InterruptedException
- if the calling thread was interrupted.
-
setAutoReceiptMode
public void setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
Configure whether theDeliveryReceiptManager
should automatically reply to incomingDeliveryReceipt
s.- 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.chat
orMessage.Type.headline
, and with aMessage.Body
extension.- 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 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
messageWithReceiptRequest
does not have a Stanza ID set, thennull
will be returned.- Parameters:
messageWithReceiptRequest
- the given message with a receipt request extension.- Returns:
- a new message with a receipt or
null
. - Since:
- 4.1
-
-