当前位置: 首页>>代码示例>>Java>>正文


Java ChatState类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.ChatState的典型用法代码示例。如果您正苦于以下问题:Java ChatState类的具体用法?Java ChatState怎么用?Java ChatState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ChatState类属于org.jivesoftware.smackx包,在下文中一共展示了ChatState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stateChanged

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void stateChanged(Chat chat, ChatState state) {
    mState = state.name();
    final int n = mRemoteListeners.beginBroadcast();

    for (int i = 0; i < n; i++) {
	IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
	try {
	    listener.stateChanged(ChatAdapter.this);
	} catch (RemoteException e) {
	    Log.w(TAG, e.getMessage());
	}
    }
    mRemoteListeners.finishBroadcast();
}
 
开发者ID:BoogieMAN2K,项目名称:Beem,代码行数:19,代码来源:ChatAdapter.java

示例2: closeChatRoom

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void closeChatRoom() {
    // If already closed, don't bother.
    if (!active) {
        return;
    }

    super.closeChatRoom();

    removeListeners();

    sendChatState(ChatState.gone);
    sendGoneNotification = false;

    SparkManager.getChatManager().removeChat(this);

    SparkManager.getConnection().removePacketListener(this);
    if (typingTimerTask != null) {
        TaskEngine.getInstance().cancelScheduledTask(typingTimerTask);
        typingTimerTask = null;
    }
    active = false;
    vcardPanel = null;

    this.removeAll();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:26,代码来源:ChatRoomImpl.java

示例3: insertUpdate

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
 * The current SendField has been updated somehow.
 *
 * @param e - the DocumentEvent to respond to.
 */
public void insertUpdate(DocumentEvent e) {
    checkForText(e);

    if (!sendChatStateNotification) {
        return;
    }
    startNotificationSendingTime = System.currentTimeMillis();

    // If the user pauses for more than two seconds, send out a new notice.
    if (sendComposingNotification) {
        try {
            //SparkManager.getMessageEventManager().sendComposingNotification(getParticipantJID(), threadID);            	
        	sendChatState(ChatState.composing);
        	
            sendPausingNotification = true;
            sendInactiveNotification = true;
            sendGoneNotification = true;
            sendComposingNotification = false;
        }            
        catch (Exception exception) {
            Log.error("Error updating", exception);
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:30,代码来源:ChatRoomImpl.java

示例4: filterIncomingMessage

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
 * Filters all incoming messages.
 *
 * @param room    the room the message belongs to.
 * @param message the message to filter.
 */
public void filterIncomingMessage(ChatRoom room, Message message) {
    // Fire Message Filters
    final ChatManager chatManager = SparkManager.getChatManager();
    Iterator<MessageFilter> filters = chatManager.getMessageFilters().iterator();
    try {
        cancelledNotification(message.getFrom(), ChatState.paused);
    }
    catch (Exception e) {
        Log.error(e);
    }

    // Notify MessageFilters.
    while (filters.hasNext()) {
        (filters.next()).filterIncoming(room, message);
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:ChatManager.java

示例5: composingNotification

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void composingNotification(final String from) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final ContactList contactList = SparkManager.getWorkspace().getContactList();

            ChatRoom chatRoom;
            try {
                chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
                if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {                    	
                    typingNotificationList.add(chatRoom);
                    // Notify Decorators
                    notifySparkTabHandlers(chatRoom);
                    ((ChatRoomImpl)chatRoom).notifyChatStateChange(ChatState.composing);
                }
            }
            catch (ChatRoomNotFoundException e) {
                // Do nothing
            }
            contactList.setIconFor(from, SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
        }
    });
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:ChatManager.java

示例6: cancelledNotification

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void cancelledNotification(final String from, final ChatState state) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ContactList contactList = SparkManager.getWorkspace().getContactList();

            ChatRoom chatRoom;
            try {
                chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
                if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
                    typingNotificationList.remove(chatRoom);
                    // Notify Decorators
                    notifySparkTabHandlers(chatRoom);
                    ((ChatRoomImpl)chatRoom).notifyChatStateChange(state);
                }
            }
            catch (ChatRoomNotFoundException e) {
                // Do nothing
            }
            contactList.useDefaults(from);
        }
    });
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:ChatManager.java

示例7: parseExtension

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:11,代码来源:ChatStateExtension.java

示例8: parseExtension

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser)
		throws Exception {
	ChatState state;
	try {
		state = ChatState.valueOf(parser.getName());
	} catch (Exception ex) {
		state = ChatState.active;
	}
	return new ChatStateExtension(state);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:11,代码来源:ChatStateExtension.java

示例9: sendChatState

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
 * @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
 */
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
    final Presence presence = conn.getRoster().getPresence(jid.toString());
    if (presence == null  || presence.getType().equals(Presence.Type.unavailable)) {
        // don't send chat state to contacts that are offline.
        return;
    }
    Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
    try {
        ChatState state = ChatState.active;
        switch (chatState) {
            case active:    state = ChatState.active;    break;
            case composing: state = ChatState.composing; break;
            case paused:    state = ChatState.paused;    break;
            case inactive:  state = ChatState.inactive;  break;
            case gone:      state = ChatState.gone;      break;
        }

        Message message = new Message();
        message.addExtension(new ChatStateExtension(state));
        chat.sendMessage(message);
    }
    catch (XMPPException e) {
        // Ignore
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:30,代码来源:XMPPSession.java

示例10: createChatStateTimerTask

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
protected void createChatStateTimerTask() {
	typingTimerTask = new TimerTask() {
        public void run() {                
            if (!sendChatStateNotification) {
                return;
            }
            long now = System.currentTimeMillis();
            long time = now - startNotificationSendingTime;
            if (inBetween(time, pauseTimePeriod, inactiveTimePeriod)) {
            	if (sendPausingNotification) {
            		// send cancel
            		//SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);
            		sendChatState(ChatState.paused);
            		sendPausingNotification = false;
            		sendComposingNotification = true;
            	}
            } else if (inBetween(time, inactiveTimePeriod, goneTimePeriod)) {
            	if(sendInactiveNotification) {
            		sendChatState(ChatState.inactive);
            		sendInactiveNotification = false;
            	}
            } else if (time > goneTimePeriod) {
            	if (sendGoneNotification) {
            		sendChatState(ChatState.gone);
            		sendGoneNotification = false;
            	}
            }                
        }
    };
    TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, pauseTimePeriod, pauseTimePeriod);      
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:32,代码来源:ChatRoomImpl.java

示例11: activateChatStateNotificationSystem

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void activateChatStateNotificationSystem() {
	startNotificationSendingTime = System.currentTimeMillis();
	sendInactiveNotification = true;    	
	sendGoneNotification = true;
	sendPausingNotification = false;
	sendComposingNotification = true;
	if (lastNotificationSent == null || !lastNotificationSent.equals(ChatState.active)) {
		sendChatState(ChatState.active);
	}
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:11,代码来源:ChatRoomImpl.java

示例12: inactivateChatStateNotificationSystem

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void inactivateChatStateNotificationSystem() {
	startNotificationSendingTime = System.currentTimeMillis();
	sendInactiveNotification = false;    	
	sendGoneNotification = true;
	sendPausingNotification = false;
	sendComposingNotification = false;
	if (lastNotificationSent != null && !lastNotificationSent.equals(ChatState.inactive) && !lastNotificationSent.equals(ChatState.gone)) {
		sendChatState(ChatState.inactive);
	}
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:11,代码来源:ChatRoomImpl.java

示例13: sendChatState

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
private void sendChatState(ChatState state) {
  	Connection connection = SparkManager.getConnection();
  	boolean connected = connection.isConnected();
if (connected) {
	Chat chat = connection.getChatManager().createChat(getParticipantJID(), null);
	try {
		ChatStateManager.getInstance(connection).setCurrentState(state, chat);
		lastNotificationSent = state;
	} catch (XMPPException e) {
		Log.error("Cannot send " + state + " chat notification");
	}
}
  }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:14,代码来源:ChatRoomImpl.java

示例14: notifyChatStateChange

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void notifyChatStateChange(ChatState state) {
	if (chatStatePanel != null) {
		getEditorWrapperBar().remove(chatStatePanel);
	}
	
	chatStatePanel = new ChatStatePanel(state, getParticipantNickname());   	
	getEditorWrapperBar().add(chatStatePanel, BorderLayout.SOUTH);
	getEditorWrapperBar().revalidate();
	getEditorWrapperBar().repaint();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:11,代码来源:ChatRoomImpl.java

示例15: ChatStatePanel

import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public ChatStatePanel(ChatState state, String nickname) {
	setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
	label = new JLabel(Res.getString(state.name(), nickname));
	label.setFont(new Font("Courier New", Font.PLAIN, 9));
	label.setForeground(Color.gray);
	label.setHorizontalTextPosition(JLabel.LEFT);
	label.setVerticalTextPosition(JLabel.BOTTOM);
	add(label);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:10,代码来源:ChatStatePanel.java


注:本文中的org.jivesoftware.smackx.ChatState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。