use of net.sf.kraken.type.ChatStateType in project Openfire by igniterealtime.
the class AbstractChatStateUtil method isActive.
/**
* Changes the chat state of the sender to 'active' in the context of a
* conversation with the receiver. Additionally, a future chat state change
* to 'inactive' is scheduled, replacing any existing scheduled chat state
* changes.
*
* If execution of this method changes the current chat state,
* {@link #sendIsActive(JID, JID)} will be triggered exactly once.
*
* The delay after which the change to the future chat state will be reset
* no matter what the current chat state is.
*
* @param sender
* The entity of which the chat state is changing.
* @param receiver
* The entity that is to receive a chat state change
* notification.
*/
public void isActive(JID sender, JID receiver) {
final ChatStateSession session = new ChatStateSession(sender, receiver);
final ChatStateType newState = ChatStateType.active;
synchronized (mutex) {
final ChatStateType previousState = currentStates.put(session, newState);
if (previousState != newState) {
sendIsActive(sender, receiver);
}
// Replace any existing timeout with a new timeout: should go to
// 'inactive' in 2 minutes
scheduleStateChange(120, TimeUnit.SECONDS, ChatStateType.inactive, session);
}
}
Aggregations