本文整理汇总了Java中org.jivesoftware.smack.packet.Message.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.jivesoftware.smack.packet.Message包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateMessageTypeWithDefaults1
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithDefaults1() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例2: validateMessageTypeWithDefaults2
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithDefaults2() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例3: validateMessageTypeWithDefaults3
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithDefaults3() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.groupchat);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例4: validateMessageTypeWithNoNormal1
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithNoNormal1() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例5: validateMessageTypeWithNoNormal2
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithNoNormal2() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例6: chatNotMatchedWithTypeNormal
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void chatNotMatchedWithTypeNormal() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket(null, false);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例7: createChatPacket
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
private Message createChatPacket(final String threadId, final boolean isFullJid) {
Message chatMsg = new Message("[email protected]", Message.Type.chat);
chatMsg.setBody("the body message - " + System.currentTimeMillis());
chatMsg.setFrom("[email protected]" + (isFullJid ? "/resource" : ""));
chatMsg.setThread(threadId);
return chatMsg;
}
示例8: initSysTemMsgManager
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
private void initSysTemMsgManager() {
initSoundPool();
XMPPConnection con = XmppConnectionManager.getInstance()
.getConnection();
con.addPacketListener(pListener, new MessageTypeFilter(
Message.Type.normal));
}
示例9: processPacket
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Override
public void processPacket(Packet packetz) {
Message message = (Message) packetz;
if (message.getType() == Type.normal) {
NoticeManager noticeManager = NoticeManager
.getInstance(context);
Notice notice = new Notice();
// playSound(1, 0); //������Ч
notice.setTitle("ϵͳ��Ϣ");
notice.setNoticeType(Notice.SYS_MSG);
notice.setFrom(packetz.getFrom());
notice.setContent(message.getBody());
notice.setNoticeTime(DateUtil.date2Str(Calendar.getInstance(),
Constant.MS_FORMART));
notice.setFrom(packetz.getFrom());
notice.setTo(packetz.getTo());
notice.setStatus(Notice.UNREAD);
long noticeId = noticeManager.saveNotice(notice);
if (noticeId != -1) {
Intent intent = new Intent();
intent.setAction(Constant.ACTION_SYS_MSG);
notice.setId(String.valueOf(noticeId));
intent.putExtra("notice", notice);
sendBroadcast(intent);
setNotiType(R.drawable.icon, Constant.SYS_MSG_DIS,
message.getBody(), MyNoticeActivity.class);
}
}
}
示例10: init
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
private void init() {
//数据业务类
mIMMsgDao = new IMMsgDao(context);
XMPPConnection con = XmppConnectionManager.getInstance()
.getConnection();
con.addPacketListener(pListener, new MessageTypeFilter(
Message.Type.normal));
}
示例11: processPacket
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
public void processPacket(final Packet packet) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
final Message message = (Message)packet;
// Do not handle errors or offline messages
final DelayInformation offlineInformation = (DelayInformation)message.getExtension("x", "jabber:x:delay");
if (offlineInformation != null || message.getError() != null) {
return;
}
boolean broadcast = message.getProperty("broadcast") != null;
if ((broadcast || message.getType() == Message.Type.normal
|| message.getType() == Message.Type.headline) && message.getBody() != null) {
showAlert((Message)packet);
}
else {
String host = SparkManager.getSessionManager().getServerAddress();
String from = packet.getFrom() != null ? packet.getFrom() : "";
if (host.equalsIgnoreCase(from) || !ModelUtil.hasLength(from)) {
showAlert((Message)packet);
}
}
}
catch (Exception e) {
Log.error(e);
}
}
});
}
示例12: validateMessageTypeWithDefaults4
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Test
public void validateMessageTypeWithDefaults4() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.headline);
assertNull(listener.getNewChat());
}
示例13: doStart
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
try {
connection = endpoint.createConnection();
} catch (SmackException e) {
if (endpoint.isTestConnectionOnStartup()) {
throw new RuntimeException("Could not connect to XMPP server.", e);
} else {
LOG.warn(e.getMessage());
if (getExceptionHandler() != null) {
getExceptionHandler().handleException(e.getMessage(), e);
}
scheduleDelayedStart();
return;
}
}
chatManager = ChatManager.getInstanceFor(connection);
chatManager.addChatListener(this);
OrFilter pubsubPacketFilter = new OrFilter();
if (endpoint.isPubsub()) {
//xep-0060: pubsub#notification_type can be 'headline' or 'normal'
pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.headline));
pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.normal));
connection.addPacketListener(this, pubsubPacketFilter);
}
if (endpoint.getRoom() == null) {
privateChat = chatManager.getThreadChat(endpoint.getChatId());
if (privateChat != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Adding listener to existing chat opened to " + privateChat.getParticipant());
}
privateChat.addMessageListener(this);
} else {
privateChat = ChatManager.getInstanceFor(connection).createChat(endpoint.getParticipant(), endpoint.getChatId(), this);
if (LOG.isDebugEnabled()) {
LOG.debug("Opening private chat to " + privateChat.getParticipant());
}
}
} else {
// add the presence packet listener to the connection so we only get packets that concerns us
// we must add the listener before creating the muc
final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class));
connection.addPacketListener(this, packetFilter);
muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
muc.addMessageListener(this);
DiscussionHistory history = new DiscussionHistory();
history.setMaxChars(0); // we do not want any historical messages
muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
if (LOG.isInfoEnabled()) {
LOG.info("Joined room: {} as: {}", muc.getRoom(), endpoint.getNickname());
}
}
this.startRobustConnectionMonitor();
super.doStart();
}
示例14: processPacket
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
@Override
public void processPacket(Packet packetz) {
Message message = (Message) packetz;
if (message != null && message.getBody() != null
&& !message.getBody().equals("null")) {
if (message.getType() == Type.normal) {
Log.i("TAG", "[服务]收到系统消息:"+message.getBody());
// 生成消息历史记录
IMMessage mIMMessage = new IMMessage();
mIMMessage.setTitle("系统信息");
mIMMessage.setContent(message.getBody());
if (Message.Type.error == message.getType()) {
mIMMessage.setSendState(IMMessage.FAILED);
} else {
mIMMessage.setSendState(IMMessage.RECEIVED);
}
mIMMessage.setType(IMMessage.SYS_MSG);
String from = message.getFrom().split("@")[0];
//发送方
mIMMessage.setUserName(from);
//接收方
mIMMessage.setToUserName(message.getTo().split("@")[0]);
mIMMessage.setReadState(IMMessage.UNREAD);
String time = AbDateUtil.getCurrentDate(AbDateUtil.dateFormatYMDHMS);
mIMMessage.setTime(time);
//保存本地
mIMMsgDao.startWritableDatabase(false);
long messageId = mIMMsgDao.insert(mIMMessage);
mIMMsgDao.closeDatabase();
if (messageId != -1) {
//发出接收到的系统消息
Intent intent = new Intent();
intent.setAction(IMConstant.ACTION_NEW_MESSAGE);
intent.setAction(IMConstant.ACTION_SYS_MESSAGE);
intent.putExtra("MESSAGE", mIMMessage);
sendBroadcast(intent);
}
}
}
}
示例15: processPacket
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
public void processPacket(Packet packet) {
if (packet instanceof GoogleMailBoxPacket) {
if (JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
GoogleMailBoxPacket mbp = (GoogleMailBoxPacket)packet;
this.setLastGMailThreadDate(mbp.getResultTime());
Integer newMailCount = 0;
String mailList = "";
for (GoogleMailThread mail : mbp.getMailThreads()) {
newMailCount++;
if (this.getLastGMailThreadId() == null || mail.getThreadId() > this.getLastGMailThreadId()) {
this.setLastGMailThreadId(mail.getThreadId());
}
String senderList = "";
for (GoogleMailSender sender : mail.getSenders()) {
if (!senderList.equals("")) {
senderList += ", ";
}
String name = sender.getName();
if (name != null) {
senderList += name + " <";
}
senderList += sender.getAddress();
if (name != null) {
senderList += ">";
}
}
mailList += "\n "+senderList+" sent "+mail.getSubject();
}
if (newMailCount > 0) {
getSession().getTransport().sendMessage(
getSession().getJID(),
getSession().getTransport().getJID(),
LocaleUtils.getLocalizedString("gateway.gtalk.mail", "kraken", Arrays.asList(newMailCount))+mailList,
Message.Type.headline
);
}
}
}
else if (packet instanceof IQ) {
Log.debug("XMPP: Got google mail notification");
GoogleNewMailExtension gnme = (GoogleNewMailExtension)packet.getExtension(GoogleNewMailExtension.ELEMENT_NAME, GoogleNewMailExtension.NAMESPACE);
if (gnme != null) {
Log.debug("XMPP: Sending google mail request");
getSession().conn.sendPacket(new IQWithPacketExtension(new GoogleMailNotifyExtension()));
}
}
}