本文整理了Java中org.jivesoftware.smack.packet.Message.getType()
方法的一些代码示例,展示了Message.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getType()
方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:getType
[英]Returns the type of the message. If no type has been set this method will return Type#normal.
[中]返回消息的类型。如果未设置类型,此方法将返回类型#normal。
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
// if it's not an error message, reset the idle time
if (message.getType() == Message.Type.error) return;
resetIdleTime();
}
}, StanzaTypeFilter.MESSAGE);
代码示例来源:origin: igniterealtime/Smack
@Override
protected boolean acceptSpecific(Message message) {
return message.getType() == type;
}
代码示例来源:origin: igniterealtime/Smack
@Override
protected boolean acceptSpecific(Message message) {
return normalIncluded ? message.getType() == Type.normal : false;
}
代码示例来源:origin: igniterealtime/Smack
public void send(Message message) throws NotConnectedException, InterruptedException {
switch (message.getType()) {
case normal:
case chat:
break;
default:
throw new IllegalArgumentException("Message must be of type 'normal' or 'chat'");
}
Jid to = lockedResource;
if (to == null) {
to = jid;
}
message.setTo(to);
connection().sendStanza(message);
}
代码示例来源:origin: igniterealtime/Smack
packetTypeIcon = messagePacketIcon;
messageType = "Message Received";
type = ((Message) packet).getType().toString();
receivedMessagePackets++;
代码示例来源:origin: igniterealtime/Smack
packetTypeIcon = messagePacketIcon;
messageType = "Message Sent";
type = ((Message) packet).getType().toString();
sentMessagePackets++;
代码示例来源:origin: igniterealtime/Smack
/**
* Create and return a new message including a delivery receipt extension for the given message.
* <p>
* If {@code messageWithReceiptRequest} does not have a Stanza ID set, then {@code null} will be returned.
* </p>
*
* @param messageWithReceiptRequest the given message with a receipt request extension.
* @return a new message with a receipt or <code>null</code>.
* @since 4.1
*/
public static Message receiptMessageFor(Message messageWithReceiptRequest) {
String stanzaId = messageWithReceiptRequest.getStanzaId();
if (StringUtils.isNullOrEmpty(stanzaId)) {
return null;
}
Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType());
message.addExtension(new DeliveryReceipt(stanzaId));
return message;
}
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void setMessageTypeTest() throws IOException, SAXException {
Message.Type type = Message.Type.chat;
Message.Type type2 = Message.Type.headline;
StringBuilder controlBuilder = new StringBuilder();
controlBuilder.append("<message")
.append(" type=\"")
.append(type)
.append("\">")
.append("</message>");
String control = controlBuilder.toString();
Message messageTypeInConstructor = new Message(null, Message.Type.chat);
messageTypeInConstructor.setStanzaId(null);
assertEquals(type, messageTypeInConstructor.getType());
assertXMLEqual(control, messageTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
controlBuilder = new StringBuilder();
controlBuilder.append("<message")
.append(" type=\"")
.append(type2)
.append("\">")
.append("</message>");
control = controlBuilder.toString();
Message messageTypeSet = getNewMessage();
messageTypeSet.setType(type2);
assertEquals(type2, messageTypeSet.getType());
assertXMLEqual(control, messageTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
代码示例来源:origin: spring-projects/spring-integration
@Override
protected Map<String, Object> extractStandardHeaders(Message source) {
Map<String, Object> headers = new HashMap<>();
Jid from = source.getFrom();
if (from != null) {
headers.put(XmppHeaders.FROM, from.toString());
}
String subject = source.getSubject();
if (StringUtils.hasText(subject)) {
headers.put(XmppHeaders.SUBJECT, subject);
}
String thread = source.getThread();
if (StringUtils.hasText(thread)) {
headers.put(XmppHeaders.THREAD, thread);
}
Jid to = source.getTo();
if (to != null) {
headers.put(XmppHeaders.TO, to.toString());
}
Message.Type type = source.getType();
if (type != null) {
headers.put(XmppHeaders.TYPE, type);
}
return headers;
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void checkMamQueryResults() throws Exception {
Message message = new Message();
message.setStanzaId("iasd207");
message.setFrom(JidCreate.from("coven@chat.shakespeare.lit"));
message.setTo(JidCreate.from("hag66@shakespeare.lit/pda"));
GregorianCalendar calendar = new GregorianCalendar(2002, 10 - 1, 13, 23, 58, 37);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
DelayInformation delay = new DelayInformation(date);
Message forwardedMessage = new Message();
forwardedMessage.setFrom(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
forwardedMessage.setStanzaId("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
forwardedMessage.setType(Type.chat);
forwardedMessage.setBody("Thrice the brinded cat hath mew.");
Forwarded forwarded = new Forwarded(delay, forwardedMessage);
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
// FIXME: The order of assertEquals is reversed, fix it by switching it.
Assert.assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
MamResultExtension mamResultExtension = MamResultExtension.from(message);
Assert.assertEquals(mamResultExtension.getId(), "34482-21985-73620");
Assert.assertEquals(mamResultExtension.getForwarded().getDelayInformation().getStamp(), date);
Message resultMessage = (Message) mamResultExtension.getForwarded().getForwardedStanza();
Assert.assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
Assert.assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
Assert.assertEquals(resultMessage.getType(), Type.chat);
Assert.assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
}
代码示例来源:origin: tiandawu/IotXmpp
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
Message.Type messageType = ((Message) packet).getType();
return messageType != Message.Type.groupchat &&
messageType != Message.Type.headline;
}
};
代码示例来源:origin: org.igniterealtime.smack/smack
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
Message.Type messageType = ((Message) packet).getType();
return messageType != Message.Type.groupchat &&
messageType != Message.Type.headline;
}
};
代码示例来源:origin: org.mobicents.resources/mobicents-slee-ra-xmpp-library
public boolean accept(Packet packet) {
Message msg = (Message)packet;
return msg.getType() == Message.Type.GROUP_CHAT;
}
});
代码示例来源:origin: org.littleshoot/smack-xmpp-3-2-2
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
Message.Type messageType = ((Message) packet).getType();
return messageType != Message.Type.groupchat &&
messageType != Message.Type.headline;
}
};
代码示例来源:origin: org.mobicents.resources/mobicents-slee-ra-xmpp-library
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
else {
return ((Message) packet).getType().equals(this.type);
}
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void fromHeadersStandardOutbound() {
DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
Map<String, Object> headerMap = new HashMap<>();
headerMap.put("userDefined1", "foo");
headerMap.put("userDefined2", "bar");
headerMap.put(XmppHeaders.THREAD, "test.thread");
headerMap.put(XmppHeaders.TO, "test.to");
headerMap.put(XmppHeaders.FROM, "test.from");
headerMap.put(XmppHeaders.SUBJECT, "test.subject");
headerMap.put(XmppHeaders.TYPE, "headline");
MessageHeaders headers = new MessageHeaders(headerMap);
Message target = new Message();
mapper.fromHeadersToRequest(headers, target);
// "standard" XMPP headers
assertEquals("test.thread", target.getThread());
assertEquals("test.to", target.getTo().toString());
assertEquals("test.from", target.getFrom().toString());
assertEquals("test.subject", target.getSubject());
assertEquals(Message.Type.headline, target.getType());
// user-defined headers not included by default
assertNull(JivePropertiesManager.getProperty(target, "userDefined1"));
assertNull(JivePropertiesManager.getProperty(target, "userDefined2"));
// transient headers should not be copied
assertNull(JivePropertiesManager.getProperty(target, "id"));
assertNull(JivePropertiesManager.getProperty(target, "timestamp"));
}
代码示例来源:origin: spring-projects/spring-integration
assertNull(target.getFrom());
assertNull(target.getSubject());
assertEquals(Message.Type.normal, target.getType());
代码示例来源:origin: org.igniterealtime.smack/smack
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
else {
return ((Message) packet).getType().equals(this.type);
}
}
代码示例来源:origin: org.littleshoot/smack-xmpp-3-2-2
public boolean accept(Packet packet) {
if (!(packet instanceof Message)) {
return false;
}
else {
return ((Message) packet).getType().equals(this.type);
}
}
代码示例来源:origin: org.springframework.ws/spring-ws-support
public static String getErrorMessage(Message message) {
if (message == null || !Message.Type.error.equals(message.getType())) {
return null;
}
else {
return message.getBody();
}
}
内容来源于网络,如有侵权,请联系作者删除!