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


Java ChatStateExtension类代码示例

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


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

示例1: setCurrentState

import org.jivesoftware.smackx.packet.ChatStateExtension; //导入依赖的package包/类
/**
 * Sets the current state of the provided chat. This method will send an empty bodied Message
 * packet with the state attached as a {@link org.jivesoftware.smack.packet.PacketExtension}, if
 * and only if the new chat state is different than the last state.
 *
 * @param newState the new state of the chat
 * @param chat the chat.
 * @throws org.jivesoftware.smack.XMPPException
 *          when there is an error sending the message
 *          packet.
 */
public void setCurrentState(ChatState newState, Chat chat) throws XMPPException {
    if(chat == null || newState == null) {
        throw new IllegalArgumentException("Arguments cannot be null.");
    }
    if(!updateChatState(chat, newState)) {
        return;
    }
    Message message = new Message();
    ChatStateExtension extension = new ChatStateExtension(newState);
    message.addExtension(extension);

    chat.sendMessage(message);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:25,代码来源:ChatStateManager.java

示例2: interceptPacket

import org.jivesoftware.smackx.packet.ChatStateExtension; //导入依赖的package包/类
public void interceptPacket(Packet packet) {
    Message message = (Message) packet;
    Chat chat = connection.getChatManager().getThreadChat(message.getThread());
    if (chat == null) {
        return;
    }
    if (updateChatState(chat, ChatState.active)) {
        message.addExtension(new ChatStateExtension(ChatState.active));
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:11,代码来源:ChatStateManager.java

示例3: setCurrentState

import org.jivesoftware.smackx.packet.ChatStateExtension; //导入依赖的package包/类
/**
 * Sets the current state of the provided chat. This method will send an
 * empty bodied Message packet with the state attached as a
 * {@link org.jivesoftware.smack.packet.PacketExtension}, if and only if the
 * new chat state is different than the last state.
 * 
 * @param newState
 *            the new state of the chat
 * @param chat
 *            the chat.
 * @throws org.jivesoftware.smack.XMPPException
 *             when there is an error sending the message packet.
 */
public void setCurrentState(ChatState newState, Chat chat)
		throws XMPPException {
	if (chat == null || newState == null) {
		throw new IllegalArgumentException("Arguments cannot be null.");
	}
	if (!updateChatState(chat, newState)) {
		return;
	}
	Message message = new Message();
	ChatStateExtension extension = new ChatStateExtension(newState);
	message.addExtension(extension);

	chat.sendMessage(message);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:28,代码来源:ChatStateManager.java

示例4: interceptPacket

import org.jivesoftware.smackx.packet.ChatStateExtension; //导入依赖的package包/类
public void interceptPacket(Packet packet) {
	Message message = (Message) packet;
	Chat chat = connection.getChatManager().getThreadChat(
			message.getThread());
	if (chat == null) {
		return;
	}
	if (updateChatState(chat, ChatState.active)) {
		message.addExtension(new ChatStateExtension(ChatState.active));
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:12,代码来源:ChatStateManager.java

示例5: sendChatState

import org.jivesoftware.smackx.packet.ChatStateExtension; //导入依赖的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


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