Package org.jivesoftware.smackx.offline
Class OfflineMessageManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.offline.OfflineMessageManager
-
public final class OfflineMessageManager extends Manager
The OfflineMessageManager helps manage offline messages even before the user has sent an available presence. When a user asks for his offline messages before sending an available presence then the server will not send a flood with all the offline messages when the user becomes online. The server will not send a flood with all the offline messages to the session that made the offline messages request or to any other session used by the user that becomes online.Once the session that made the offline messages request has been closed and the user becomes offline in all the resources then the server will resume storing the messages offline and will send all the offline messages to the user when he becomes online. Therefore, the server will flood the user when he becomes online unless the user uses this class to manage his offline messages.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteMessages()
Deletes all offline messages of the user.void
deleteMessages(List<String> nodes)
Deletes the specified list of offline messages.List<OfflineMessageHeader>
getHeaders()
Returns a List ofOfflineMessageHeader
that keep information about the offline message.static OfflineMessageManager
getInstanceFor(XMPPConnection connection)
int
getMessageCount()
Returns the number of offline messages for the user of the connection.List<Message>
getMessages()
Returns a List of Messages with all the offlineMessages
of the user.List<Message>
getMessages(List<String> nodes)
Returns a List of the offlineMessages
whose stamp matches the specified request.boolean
supportsFlexibleRetrieval()
Returns true if the server supports Flexible Offline Message Retrieval.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstanceFor
public static OfflineMessageManager getInstanceFor(XMPPConnection connection)
-
supportsFlexibleRetrieval
public boolean supportsFlexibleRetrieval() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns true if the server supports Flexible Offline Message Retrieval. When the server supports Flexible Offline Message Retrieval it is possible to get the header of the offline messages, get specific messages, delete specific messages, etc.- Returns:
- a boolean indicating if the server supports Flexible Offline Message Retrieval.
- Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getMessageCount
public int getMessageCount() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns the number of offline messages for the user of the connection.- Returns:
- the number of offline messages for the user of the connection.
- Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getHeaders
public List<OfflineMessageHeader> getHeaders() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns a List ofOfflineMessageHeader
that keep information about the offline message. The OfflineMessageHeader includes a stamp that could be used to retrieve the complete message or delete the specific message.- Returns:
- a List of
OfflineMessageHeader
that keep information about the offline message. - Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getMessages
public List<Message> getMessages(List<String> nodes) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns a List of the offlineMessages
whose stamp matches the specified request. The request will include the list of stamps that uniquely identifies the offline messages to retrieve. The returned offline messages will not be deleted from the server. UsedeleteMessages(java.util.List)
to delete the messages.- Parameters:
nodes
- the list of stamps that uniquely identifies offline message.- Returns:
- a List with the offline
Messages
that were received as part of this request. - Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getMessages
public List<Message> getMessages() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns a List of Messages with all the offlineMessages
of the user. The returned offline messages will not be deleted from the server. UsedeleteMessages(java.util.List)
to delete the messages.- Returns:
- a List with all the offline
Messages
of the user. - Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deleteMessages
public void deleteMessages(List<String> nodes) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Deletes the specified list of offline messages. The request will include the list of stamps that uniquely identifies the offline messages to delete.- Parameters:
nodes
- the list of stamps that uniquely identifies offline message.- Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deleteMessages
public void deleteMessages() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Deletes all offline messages of the user.- Throws:
XMPPException.XMPPErrorException
- If the user is not allowed to make this request or the server does not support offline message retrieval.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
-