Class OfflineMessageManager

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.offline.OfflineMessageManager

public final class OfflineMessageManager extends org.jivesoftware.smack.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.

  • Field Details

  • Method Details

    • getInstanceFor

      public static OfflineMessageManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
    • supportsFlexibleRetrieval

      public boolean supportsFlexibleRetrieval() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • getMessageCount

      public int getMessageCount() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • getHeaders

      public List<OfflineMessageHeader> getHeaders() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Returns a List of OfflineMessageHeader 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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • getMessages

      public List<org.jivesoftware.smack.packet.Message> getMessages(List<String> nodes) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Returns a List of the offline Messages 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. Use deleteMessages(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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • getMessages

      public List<org.jivesoftware.smack.packet.Message> getMessages() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Returns a List of Messages with all the offline Messages of the user. The returned offline messages will not be deleted from the server. Use deleteMessages(java.util.List) to delete the messages.
      Returns:
      a List with all the offline Messages of the user.
      Throws:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • deleteMessages

      public void deleteMessages(List<String> nodes) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • deleteMessages

      public void deleteMessages() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Deletes all offline messages of the user.
      Throws:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If the user is not allowed to make this request or the server does not support offline message retrieval.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the server.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.