Class ChatStateManager

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.chatstates.ChatStateManager

public final class ChatStateManager extends org.jivesoftware.smack.Manager
Handles chat state for all chats on a particular XMPPConnection. This class manages both the stanza extensions and the disco response necessary for compliance with XEP-0085. NOTE: getInstance(org.jivesoftware.smack.XMPPConnection) needs to be called in order for the listeners to be registered appropriately with the connection. If this does not occur you will not receive the update notifications.
See Also:
  • Field Details

  • Method Details

    • getInstance

      public static ChatStateManager getInstance(org.jivesoftware.smack.XMPPConnection connection)
      Returns the ChatStateManager related to the XMPPConnection and it will create one if it does not yet exist.
      Parameters:
      connection - the connection to return the ChatStateManager
      Returns:
      the ChatStateManager related the connection.
    • addChatStateListener

      public boolean addChatStateListener(ChatStateListener listener)
      Register a ChatStateListener. That listener will be informed about changed chat states.
      Parameters:
      listener - chatStateListener
      Returns:
      true, if the listener was not registered before
    • removeChatStateListener

      public boolean removeChatStateListener(ChatStateListener listener)
      Unregister a ChatStateListener.
      Parameters:
      listener - chatStateListener
      Returns:
      true, if the listener was registered before
    • setCurrentState

      public void setCurrentState(ChatState newState, Chat chat) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Sets the current state of the provided chat. This method will send an empty bodied Message stanza with the state attached as a ExtensionElement, if and only if the new chat state is different than the last state.
      Parameters:
      newState - the new state of the chat
      chat - the chat.
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object