/** * 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); }
/** * 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); }
/** * 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); }
public void send(CharSequence message) throws NotConnectedException, InterruptedException { Message stanza = new Message(); stanza.setBody(message); stanza.setType(Message.Type.chat); send(stanza); }
/** * 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); }
@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()); }
@Test public void validateMessageTypeWithDefaults4() { Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.headline); assertNull(listener.getNewChat()); }
@Test public void validateMessageTypeWithDefaults1() { Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.chat); processServerMessage(incomingChat); assertNotNull(listener.getNewChat()); }
@Test public void validateMessageTypeWithDefaults2() { Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.normal); processServerMessage(incomingChat); assertNotNull(listener.getNewChat()); } @Test
@Test public void validateMessageTypeWithDefaults3() { Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.groupchat); processServerMessage(incomingChat); assertNull(listener.getNewChat()); }
String typeString = parser.getAttributeValue("", "type"); if (typeString != null) { message.setType(Message.Type.fromString(typeString));
@Test public void chatNotMatchedWithTypeNormal() { cm.setNormalIncluded(false); Message incomingChat = createChatPacket(null, false); incomingChat.setType(Type.normal); processServerMessage(incomingChat); assertNull(listener.getNewChat()); }
@Test public void validateMessageTypeWithNoNormal2() { cm.setNormalIncluded(false); Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.normal); processServerMessage(incomingChat); assertNull(listener.getNewChat()); }
@Test public void validateMessageTypeWithNoNormal1() { cm.setNormalIncluded(false); Message incomingChat = createChatPacket("134", true); incomingChat.setType(Type.chat); processServerMessage(incomingChat); assertNotNull(listener.getNewChat()); }
@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."); }
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");
target.setType((Message.Type) typeHeader);
@Override public void dispatch(Message message) throws XMPPException { message.setType(Message.Type.chat); chat.sendMessage(message); } }
public void dispatch(Message message) throws XMPPException { message.setType(Message.Type.groupchat); message.setTo(recipient); chat.sendMessage(message); }
public void dispatch(Message message) { message.setType(Message.Type.normal); message.setTo(recipient); connection.sendPacket(message); } }