本文整理汇总了Java中org.jivesoftware.smackx.chatstates.ChatState类的典型用法代码示例。如果您正苦于以下问题:Java ChatState类的具体用法?Java ChatState怎么用?Java ChatState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChatState类属于org.jivesoftware.smackx.chatstates包,在下文中一共展示了ChatState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTypingStatus
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的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();
}
}
示例2: processWakefulStanza
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
@Override
protected void processWakefulStanza(Stanza packet) throws SmackException.NotConnectedException {
org.jivesoftware.smack.packet.Message m = (org.jivesoftware.smack.packet.Message) packet;
if (m.getType() == org.jivesoftware.smack.packet.Message.Type.chat) {
ExtensionElement chatstate = processChatState(m);
// non-active chat states are not to be processed as messages
if (chatstate == null || chatstate.getElementName().equals(ChatState.active.name())) {
processChatMessage(m);
}
}
// error message
else if (m.getType() == org.jivesoftware.smack.packet.Message.Type.error) {
processErrorMessage(m);
}
}
示例3: sendGroupTextMessage
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void sendGroupTextMessage(final Context context, String groupJid,
String groupSubject, String[] to,
String text, boolean encrypt, long msgId, String packetId, long inReplyTo) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", TextComponent.MIME_TYPE);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.group.subject", groupSubject);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.body", text);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
i.putExtra("org.kontalk.message.inReplyTo", inReplyTo);
context.startService(i);
}
示例4: addGroupMembers
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void addGroupMembers(final Context context, String groupJid,
String groupSubject, String[] to, String[] members, boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.group.subject", groupSubject);
i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_MEMBERS);
i.putExtra("org.kontalk.message.group.add", members);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例5: removeGroupMembers
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void removeGroupMembers(final Context context, String groupJid,
String groupSubject, String[] to, String[] members, boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.group.subject", groupSubject);
i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_MEMBERS);
i.putExtra("org.kontalk.message.group.remove", members);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例6: sendBinaryMessage
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
/**
* Sends a binary message.
*/
public static void sendBinaryMessage(final Context context,
String to,
String mime, Uri localUri, long length, String previewPath,
boolean encrypt, int compress,
long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", mime);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.media.uri", localUri.toString());
i.putExtra("org.kontalk.message.length", length);
i.putExtra("org.kontalk.message.preview.path", previewPath);
i.putExtra("org.kontalk.message.compress", compress);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例7: sendGroupBinaryMessage
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void sendGroupBinaryMessage(final Context context, String groupJid, String[] to,
String mime, Uri localUri, long length, String previewPath,
boolean encrypt, int compress, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", mime);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.media.uri", localUri.toString());
i.putExtra("org.kontalk.message.length", length);
i.putExtra("org.kontalk.message.preview.path", previewPath);
i.putExtra("org.kontalk.message.compress", compress);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例8: sendLocationMessage
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
/**
* Sends a location message
*/
public static void sendLocationMessage(final Context context, String to, String text,
double lat, double lon, String geoText, String geoStreet, boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", LocationComponent.MIME_TYPE);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.body", text);
i.putExtra("org.kontalk.message.geo_lat", lat);
i.putExtra("org.kontalk.message.geo_lon", lon);
if (geoText != null)
i.putExtra("org.kontalk.message.geo_text", geoText);
if (geoStreet != null)
i.putExtra("org.kontalk.message.geo_street", geoStreet);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例9: sendGroupLocationMessage
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
/**
* Sends group location message
*/
public static void sendGroupLocationMessage(final Context context, String groupJid,
String groupSubject, String[] to,
String text, double lat, double lon, String geoText, String geoStreet, boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", LocationComponent.MIME_TYPE);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.group.subject", groupSubject);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.body", text);
i.putExtra("org.kontalk.message.geo_lat", lat);
i.putExtra("org.kontalk.message.geo_lon", lon);
if (geoText != null)
i.putExtra("org.kontalk.message.geo_text", geoText);
if (geoStreet != null)
i.putExtra("org.kontalk.message.geo_street", geoStreet);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例10: sendGroupUploadedMedia
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void sendGroupUploadedMedia(final Context context, String groupJid, String[] to,
String mime, Uri localUri, long length, String previewPath, String fetchUrl,
boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", mime);
i.putExtra("org.kontalk.message.group.jid", groupJid);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.preview.uri", localUri.toString());
i.putExtra("org.kontalk.message.length", length);
i.putExtra("org.kontalk.message.preview.path", previewPath);
i.putExtra("org.kontalk.message.body", fetchUrl);
i.putExtra("org.kontalk.message.fetch.url", fetchUrl);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例11: sendUploadedMedia
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
public static void sendUploadedMedia(final Context context, String to,
String mime, Uri localUri, long length, String previewPath, String fetchUrl,
boolean encrypt, long msgId, String packetId) {
Intent i = new Intent(context, MessageCenterService.class);
i.setAction(MessageCenterService.ACTION_MESSAGE);
i.putExtra("org.kontalk.message.msgId", msgId);
i.putExtra("org.kontalk.message.packetId", packetId);
i.putExtra("org.kontalk.message.mime", mime);
i.putExtra("org.kontalk.message.to", to);
i.putExtra("org.kontalk.message.preview.uri", localUri.toString());
i.putExtra("org.kontalk.message.length", length);
i.putExtra("org.kontalk.message.preview.path", previewPath);
i.putExtra("org.kontalk.message.body", fetchUrl);
i.putExtra("org.kontalk.message.fetch.url", fetchUrl);
i.putExtra("org.kontalk.message.encrypt", encrypt);
i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
context.startService(i);
}
示例12: handleState
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
private void handleState(ChatState state) {
if (mScheduledStateSet != null)
// whatever we wanted to set next, thats obsolete now
mScheduledStateSet.cancel();
if (state != mCurrentState)
this.setNewState(state);
if (state == ChatState.composing) {
mScheduledStateSet = new TimerTask() {
@Override
public void run() {
// NOTE: using 'inactive' instead of 'paused' here as
// 'inactive' isn't send at all
MyChatState.this.handleState(ChatState.inactive);
}
};
mTimer.schedule(mScheduledStateSet,
TimeUnit.SECONDS.toMillis(COMPOSING_TO_PAUSED));
}
}
示例13: setNewState
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
private void setNewState(ChatState state) {
// currently set states from XEP-0085: active, inactive, composing
mCurrentState = state;
if (state == ChatState.active || !(mChat instanceof SingleChat))
// don't send for groups (TODO (?))
// 'active' is send inside a message
return;
Contact contact = ((SingleChat) mChat).getMember().getContact();
if (contact.isMe() || contact.isBlocked() || contact.isDeleted())
return;
if (Config.getInstance().getBoolean(Config.NET_SEND_CHAT_STATE))
mClient.sendChatState(contact.getJID(), mChat.getXMPPID(), state);
}
示例14: onChatStateNotification
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
/**
* Inform model (and view) about a received chat state notification.
*/
public void onChatStateNotification(MessageIDs ids,
Optional<Date> serverDate,
ChatState chatState) {
if (serverDate.isPresent()) {
long diff = new Date().getTime() - serverDate.get().getTime();
if (diff > TimeUnit.SECONDS.toMillis(10)) {
// too old
return;
}
}
Contact contact = mModel.contacts().get(ids.jid).orElse(null);
if (contact == null) {
LOGGER.info("can't find contact with jid: "+ids.jid);
return;
}
// NOTE: assume chat states are only send for single chats
SingleChat chat = mModel.chats().get(contact, ids.xmppThreadID).orElse(null);
if (chat == null)
// not that important
return;
chat.setChatState(contact, chatState);
}
示例15: sendInactiveTypingStatus
import org.jivesoftware.smackx.chatstates.ChatState; //导入依赖的package包/类
private void sendInactiveTypingStatus() {
if (wasComposingMessage()) {
mRoomManager.updateTypingStatus(ChatState.paused, mChatJID, mChat.getType());
} else {
mRoomManager.updateTypingStatus(ChatState.inactive, mChatJID, mChat.getType());
}
}