本文整理汇总了Java中org.jivesoftware.smackx.chatstates.packet.ChatStateExtension类的典型用法代码示例。如果您正苦于以下问题:Java ChatStateExtension类的具体用法?Java ChatStateExtension怎么用?Java ChatStateExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChatStateExtension类属于org.jivesoftware.smackx.chatstates.packet包,在下文中一共展示了ChatStateExtension类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateTypingStatus
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
public void updateTypingStatus(final ChatState chatState, final String jid, final int chatType) {
if (!Preferences.isTesting()) {
new Thread(new Runnable() {
@Override
public void run() {
try {
Message message = new Message(JidCreate.from(jid));
message.addExtension(new ChatStateExtension(chatState));
if (chatType == Chat.TYPE_1_T0_1) {
message.setType(Message.Type.chat);
} else {
message.setType(Message.Type.groupchat);
}
sendMessageDependingOnType(message, jid, chatType);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
}
开发者ID:esl,项目名称:mangosta-android,代码行数:24,代码来源:RoomManager.java
示例2: processStanza
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
@Override
public void processStanza(Stanza p) {
// NOTE: the packet is not the acknowledgement itself but the packet
// that is acknowledged
if (!(p instanceof Message)) {
// we are only interested in acks for messages
return;
}
Message m = (Message) p;
LOGGER.config("for message: "+m);
if (DeliveryReceipt.from(m) != null) {
// this is an ack for a 'received' message (XEP-0184) send by
// KonMessageListener, ignore
return;
}
if (m.getBody() == null && m.getExtensions().size() == 1 &&
m.getExtension(ChatStateExtension.NAMESPACE) != null) {
// this is an ack for a chat state notification (XEP-0085), ignore
return;
}
mControl.onMessageSent(MessageIDs.to(m));
}
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:27,代码来源:AcknowledgedListener.java
示例3: setCurrentState
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
/**
* Sets the current state of the provided chat. This method will send an empty bodied Message
* stanza(/packet) with the state attached as a {@link org.jivesoftware.smack.packet.ExtensionElement}, 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 NotConnectedException
*/
public void setCurrentState(ChatState newState, Chat chat) throws NotConnectedException {
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:TTalkIM,项目名称:Smack,代码行数:23,代码来源:ChatStateManager.java
示例4: processMessage
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
@Override
public void processMessage(Message message) {
Chat chat = chatManager.getThreadChat(message.getThread());
if (chat == null) {
return;
}
if (updateChatState(chat, ChatState.active)) {
message.addExtension(new ChatStateExtension(ChatState.active));
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:ChatStateManager.java
示例5: sendChatState
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
public void sendChatState(JID jid, String threadID, ChatState state) {
Message message = new Message(jid.toBareSmack(), Message.Type.chat);
if (!threadID.isEmpty())
message.setThread(threadID);
message.addExtension(new ChatStateExtension(state));
this.sendPacket(message);
}
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:9,代码来源:Client.java
示例6: processChatMessage
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension; //导入依赖的package包/类
private void processChatMessage(Message m) {
LOGGER.config("message: "+m);
// note: thread and subject are null if message comes from the Kontalk
// Android client
MessageIDs ids = MessageIDs.from(m);
Date delayDate = getDelay(m);
// process possible chat state notification (XEP-0085)
ExtensionElement csExt = m.getExtension(ChatStateExtension.NAMESPACE);
ChatState chatState = null;
if (csExt != null) {
chatState = ((ChatStateExtension) csExt).getChatState();
mControl.onChatStateNotification(ids,
Optional.ofNullable(delayDate),
chatState);
}
// must be an incoming message
// get content/text from body and/or encryption/url extension
MessageContent content = ClientUtils.parseMessageContent(m, false);
// make sure not to save a message without content
if (content.isEmpty()) {
if (chatState == null) {
LOGGER.warning("can't find any content in message");
} else if (chatState == ChatState.active) {
LOGGER.info("only active chat state");
}
return;
}
// add message
mControl.onNewInMessage(ids, Optional.ofNullable(delayDate), content);
// send a 'received' for a receipt request (XEP-0184)
DeliveryReceiptRequest request = DeliveryReceiptRequest.from(m);
if (request != null && !ids.xmppID.isEmpty()) {
Message received = new Message(m.getFrom(), Message.Type.chat);
received.addExtension(new DeliveryReceipt(ids.xmppID));
mClient.sendPacket(received);
}
}
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:45,代码来源:KonMessageListener.java
注:本文中的org.jivesoftware.smackx.chatstates.packet.ChatStateExtension类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论