本文整理了Java中org.jivesoftware.smack.packet.Message.setType()
方法的一些代码示例,展示了Message.setType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setType()
方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:setType
[英]Sets the type of the message.
[中]设置消息的类型。
代码示例来源:origin: igniterealtime/Smack
/**
* Creates a new message of the specified type to a recipient.
*
* @param to the user to send the message to.
* @param type the message type.
*/
public Message(Jid to, Type type) {
this(to);
setType(type);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Sends a Message to the chat room.
*
* @param message the message.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
message.setTo(room);
message.setType(Message.Type.groupchat);
connection.sendStanza(message);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Sends a Message to the chat room.
*
* @param message
* the message.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
message.setTo(room);
message.setType(Message.Type.groupchat);
connection.sendStanza(message);
}
代码示例来源:origin: igniterealtime/Smack
public void send(CharSequence message) throws NotConnectedException, InterruptedException {
Message stanza = new Message();
stanza.setBody(message);
stanza.setType(Message.Type.chat);
send(stanza);
}
代码示例来源:origin: igniterealtime/Smack
/**
* Sends a message to the other chat participant. The thread ID, recipient,
* and message type of the message will automatically set to those of this chat.
*
* @param message the message to send.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
// Force the recipient, message type, and thread ID since the user elected
// to send the message through this chat object.
message.setTo(participant);
message.setType(Message.Type.chat);
message.setThread(threadID);
chatManager.sendMessage(this, 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: igniterealtime/Smack
@Test
public void validateMessageTypeWithDefaults4() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.headline);
assertNull(listener.getNewChat());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void validateMessageTypeWithDefaults1() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void validateMessageTypeWithDefaults2() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
@Test
代码示例来源:origin: igniterealtime/Smack
@Test
public void validateMessageTypeWithDefaults3() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.groupchat);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
代码示例来源:origin: igniterealtime/Smack
String typeString = parser.getAttributeValue("", "type");
if (typeString != null) {
message.setType(Message.Type.fromString(typeString));
代码示例来源:origin: igniterealtime/Smack
@Test
public void chatNotMatchedWithTypeNormal() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket(null, false);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void validateMessageTypeWithNoNormal2() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void validateMessageTypeWithNoNormal1() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
代码示例来源: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: igniterealtime/Smack
msg2.setTo(conOne.getUser().asBareJid());
msg2.setThread(msg.getThread());
msg2.setType(Message.Type.chat);
msg2.setBody("To enter a case please fill out this form and send it back to me");
代码示例来源:origin: spring-projects/spring-integration
target.setType((Message.Type) typeHeader);
代码示例来源:origin: org.mule.transports/mule-transport-xmpp
@Override
public void dispatch(Message message) throws XMPPException
{
message.setType(Message.Type.chat);
chat.sendMessage(message);
}
}
代码示例来源:origin: org.mule.transports/mule-transport-xmpp
public void dispatch(Message message) throws XMPPException
{
message.setType(Message.Type.groupchat);
message.setTo(recipient);
chat.sendMessage(message);
}
代码示例来源:origin: org.mule.transports/mule-transport-xmpp
public void dispatch(Message message)
{
message.setType(Message.Type.normal);
message.setTo(recipient);
connection.sendPacket(message);
}
}
内容来源于网络,如有侵权,请联系作者删除!