Class MessageEventManager


  • public final class MessageEventManager
    extends Manager
    Manages message events requests and notifications. A MessageEventManager provides a high level access to request for notifications and send event notifications. It also provides an easy way to hook up custom logic when requests or notifications are received.
    See Also:
    XEP-22: Message Events
    • Method Detail

      • addNotificationsRequests

        public static void addNotificationsRequests​(Message message,
                                                    boolean offline,
                                                    boolean delivered,
                                                    boolean displayed,
                                                    boolean composing)
        Adds event notification requests to a message. For each event type that the user wishes event notifications from the message recipient for, true should be passed in to this method.
        Parameters:
        message - the message to add the requested notifications.
        offline - specifies if the offline event is requested.
        delivered - specifies if the delivered event is requested.
        displayed - specifies if the displayed event is requested.
        composing - specifies if the composing event is requested.
      • addMessageEventRequestListener

        public void addMessageEventRequestListener​(MessageEventRequestListener messageEventRequestListener)
        Adds a message event request listener. The listener will be fired anytime a request for event notification is received.
        Parameters:
        messageEventRequestListener - a message event request listener.
      • removeMessageEventRequestListener

        public void removeMessageEventRequestListener​(MessageEventRequestListener messageEventRequestListener)
        Removes a message event request listener. The listener will be fired anytime a request for event notification is received.
        Parameters:
        messageEventRequestListener - a message event request listener.
      • addMessageEventNotificationListener

        public void addMessageEventNotificationListener​(MessageEventNotificationListener messageEventNotificationListener)
        Adds a message event notification listener. The listener will be fired anytime a notification event is received.
        Parameters:
        messageEventNotificationListener - a message event notification listener.
      • removeMessageEventNotificationListener

        public void removeMessageEventNotificationListener​(MessageEventNotificationListener messageEventNotificationListener)
        Removes a message event notification listener. The listener will be fired anytime a notification event is received.
        Parameters:
        messageEventNotificationListener - a message event notification listener.
      • sendDeliveredNotification

        public void sendDeliveredNotification​(Jid to,
                                              java.lang.String packetID)
                                       throws SmackException.NotConnectedException,
                                              java.lang.InterruptedException
        Sends the notification that the message was delivered to the sender of the original message.
        Parameters:
        to - the recipient of the notification.
        packetID - the id of the message to send.
        Throws:
        SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • sendDisplayedNotification

        public void sendDisplayedNotification​(Jid to,
                                              java.lang.String packetID)
                                       throws SmackException.NotConnectedException,
                                              java.lang.InterruptedException
        Sends the notification that the message was displayed to the sender of the original message.
        Parameters:
        to - the recipient of the notification.
        packetID - the id of the message to send.
        Throws:
        SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • sendComposingNotification

        public void sendComposingNotification​(Jid to,
                                              java.lang.String packetID)
                                       throws SmackException.NotConnectedException,
                                              java.lang.InterruptedException
        Sends the notification that the receiver of the message is composing a reply.
        Parameters:
        to - the recipient of the notification.
        packetID - the id of the message to send.
        Throws:
        SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • sendCancelledNotification

        public void sendCancelledNotification​(Jid to,
                                              java.lang.String packetID)
                                       throws SmackException.NotConnectedException,
                                              java.lang.InterruptedException
        Sends the notification that the receiver of the message has cancelled composing a reply.
        Parameters:
        to - the recipient of the notification.
        packetID - the id of the message to send.
        Throws:
        SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.