Search in sources :

Example 6 with ChatStateType

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);
    }
}
Also used : ChatStateType(net.sf.kraken.type.ChatStateType)

Aggregations

ChatStateType (net.sf.kraken.type.ChatStateType)6 AttentionExtension (net.sf.kraken.protocols.xmpp.packet.AttentionExtension)1 IQWithPacketExtension (net.sf.kraken.protocols.xmpp.packet.IQWithPacketExtension)1 PacketExtension (org.jivesoftware.smack.packet.PacketExtension)1 ChatStateExtension (org.jivesoftware.smackx.packet.ChatStateExtension)1 DelayInformation (org.jivesoftware.smackx.packet.DelayInformation)1 JID (org.xmpp.packet.JID)1