Class ChatStateManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.chatstates.ChatStateManager
-
public final class ChatStateManager extends 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(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.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
NAMESPACE
public static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static ChatStateManager getInstance(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 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:
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
-
-