Class ChatStateManager
java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.chatstates.ChatStateManager
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addChatStateListener
(ChatStateListener listener) Register a ChatStateListener.boolean
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 Details
-
NAMESPACE
- See Also:
-
-
Method Details
-
getInstance
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
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
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, 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.InterruptedException
- if the calling thread was interrupted.
-
equals
-
hashCode
-