本文整理汇总了Java中org.jivesoftware.smack.packet.Message.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.jivesoftware.smack.packet.Message包,在下文中一共展示了Type类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:ChatConnectionTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:ChatConnectionTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:ChatConnectionTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:ChatConnectionTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:ChatConnectionTest.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:ChatConnectionTest.java
示例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;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:ChatConnectionTest.java
示例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));
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:8,代码来源:IMSystemMsgService.java
示例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);
}
}
}
开发者ID:ice-coffee,项目名称:EIM,代码行数:35,代码来源:IMSystemMsgService.java
示例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));
}
开发者ID:jingshauizh,项目名称:androidsummary,代码行数:9,代码来源:IMSystemMsgService.java
示例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);
}
}
});
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:34,代码来源:BroadcastPlugin.java
示例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());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:7,代码来源:ChatConnectionTest.java
示例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();
}
开发者ID:HydAu,项目名称:Camel,代码行数:64,代码来源:XmppConsumer.java
示例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);
}
}
}
}
开发者ID:jingshauizh,项目名称:androidsummary,代码行数:51,代码来源:IMSystemMsgService.java
示例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()));
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:48,代码来源:XMPPListener.java
示例16: showAlert
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
/**
* Show Server Alert.
*
* @param message the message to show.
* @param type
*/
private void showAlert(Message message) {
Type type = message.getType();
// Do not show alert if the message is an error.
if (message.getError() != null) {
return;
}
final String body = message.getBody();
String subject = message.getSubject();
StringBuffer buf = new StringBuffer();
if (subject != null) {
buf.append(Res.getString("subject")).append(": ").append(subject);
buf.append("\n\n");
}
buf.append(body);
String from = message.getFrom() != null ? message.getFrom() : "";
final TranscriptWindow window = new TranscriptWindow();
window.insertPrefixAndMessage(null, buf.toString(), ChatManager.TO_COLOR);
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
p.add(window, BorderLayout.CENTER);
p.setBorder(BorderFactory.createLineBorder(Color.lightGray));
// Count the number of linebreaks <br> and \n
String s = message.getBody();
s = s.replace("<br/>", "\n");
s = s.replace("<br>", "\n");
int linebreaks = org.jivesoftware.spark.util.StringUtils.
countNumberOfOccurences(s,'\n');
// Currently Serverbroadcasts dont contain Subjects, so this might be a MOTD message
boolean mightbeMOTD = message.getSubject()!=null;
if (!from.contains("@")) {
// if theres no "@" it means the message came from the server
if (Default.getBoolean(Default.BROADCAST_IN_CHATWINDOW)
|| linebreaks > 20 || message.getBody().length() > 1000 || mightbeMOTD) {
// if we have more than 20 linebreaks or the message is longer
// than 1000characters we should broadcast
// in a normal chatwindow
broadcastInChat(message);
} else {
broadcastWithPanel(message);
}
}
else if (message.getFrom() != null) {
userToUserBroadcast(message, type, from);
}
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:63,代码来源:BroadcastPlugin.java
示例17: MessageTypeFilter
import org.jivesoftware.smack.packet.Message.Type; //导入依赖的package包/类
/**
* Creates a new message type filter using the specified message type.
*
* @param type the message type.
*/
private MessageTypeFilter(Message.Type type) {
super(Message.class);
this.type = type;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:MessageTypeFilter.java
注:本文中的org.jivesoftware.smack.packet.Message.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论