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:
ChatState
,ChatStateExtension
-
-
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 boolean
addChatStateListener(ChatStateListener listener)
Register a ChatStateListener.boolean
equals(java.lang.Object o)
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.int
hashCode()
boolean
removeChatStateListener(ChatStateListener listener)
Unregister a ChatStateListener.void
setCurrentState(ChatState newState, Chat chat)
Sets the current state of the provided chat.
-
-
-
Field Detail
-
NAMESPACE
public static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 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, java.lang.InterruptedException
Sets the current state of the provided chat. This method will send an empty bodied Message stanza with the state attached as aExtensionElement
, if and only if the new chat state is different than the last state.- Parameters:
newState
- the new state of the chatchat
- the chat.- Throws:
org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-