Class 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 Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NAMESPACE  
    • 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​(java.util.List<java.lang.String> nodes)
      Deletes the specified list of offline messages.
      java.util.List<OfflineMessageHeader> getHeaders()
      Returns a List of OfflineMessageHeader that keep information about the offline message.
      static OfflineMessageManager getInstanceFor​(org.jivesoftware.smack.XMPPConnection connection)  
      int getMessageCount()
      Returns the number of offline messages for the user of the connection.
      java.util.List<org.jivesoftware.smack.packet.Message> getMessages()
      Returns a List of Messages with all the offline Messages of the user.
      java.util.List<org.jivesoftware.smack.packet.Message> getMessages​(java.util.List<java.lang.String> nodes)
      Returns a List of the offline Messages 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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,
                                                 java.lang.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.
        java.lang.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,
                                   java.lang.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.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getHeaders

        public java.util.List<OfflineMessageHeader> getHeaders()
                                                        throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                               org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                               org.jivesoftware.smack.SmackException.NotConnectedException,
                                                               java.lang.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.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getMessages

        public java.util.List<org.jivesoftware.smack.packet.Message> getMessages​(java.util.List<java.lang.String> nodes)
                                                                          throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                                                 org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                                                 org.jivesoftware.smack.SmackException.NotConnectedException,
                                                                                 java.lang.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.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getMessages

        public java.util.List<org.jivesoftware.smack.packet.Message> getMessages()
                                                                          throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                                                 org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                                                 org.jivesoftware.smack.SmackException.NotConnectedException,
                                                                                 java.lang.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.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • deleteMessages

        public void deleteMessages​(java.util.List<java.lang.String> nodes)
                            throws org.jivesoftware.smack.SmackException.NoResponseException,
                                   org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                   org.jivesoftware.smack.SmackException.NotConnectedException,
                                   java.lang.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.
        java.lang.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,
                                   java.lang.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.
        java.lang.InterruptedException - if the calling thread was interrupted.