Search in sources :

Example 1 with Message

use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.

the class Chat method sendMessage.

/**
     * Sends the specified text as a message to the other chat participant.
     * This is a convenience method for:
     *
     * <pre>
     *     Message message = chat.createMessage();
     *     message.setBody(messageText);
     *     chat.sendMessage(message);
     * </pre>
     *
     * @param text the text to send.
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void sendMessage(String text) throws NotConnectedException, InterruptedException {
    Message message = new Message();
    message.setBody(text);
    sendMessage(message);
}
Also used : Message(org.jivesoftware.smack.packet.Message)

Example 2 with Message

use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.

the class ChatConnectionTest method validateMessageTypeWithDefaults4.

@Test
public void validateMessageTypeWithDefaults4() {
    Message incomingChat = createChatPacket("134", true);
    incomingChat.setType(Type.headline);
    assertNull(listener.getNewChat());
}
Also used : Message(org.jivesoftware.smack.packet.Message) Test(org.junit.Test)

Example 3 with Message

use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.

the class ChatConnectionTest method validateMessageTypeWithDefaults1.

@Test
public void validateMessageTypeWithDefaults1() {
    Message incomingChat = createChatPacket("134", true);
    incomingChat.setType(Type.chat);
    processServerMessage(incomingChat);
    assertNotNull(listener.getNewChat());
}
Also used : Message(org.jivesoftware.smack.packet.Message) Test(org.junit.Test)

Example 4 with Message

use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.

the class JivePropertiesExtensionTest method checkProvider.

@Test
public void checkProvider() throws Exception {
    // @formatter:off
    String properties = "<message from='romeo@example.net/orchard' to='juliet@example.com/balcony'>" + "<body>Neither, fair saint, if either thee dislike.</body>" + "<properties xmlns='http://www.jivesoftware.com/xmlns/xmpp/properties'>" + "<property>" + "<name>FooBar</name>" + "<value type='integer'>42</value>" + "</property>" + "</properties>" + "</message>";
    // @formatter:on
    Message message = (Message) PacketParserUtils.parseStanza(properties);
    JivePropertiesExtension jpe = JivePropertiesExtension.from(message);
    assertNotNull(jpe);
    Integer integer = (Integer) jpe.getProperty("FooBar");
    assertNotNull(integer);
    int fourtytwo = integer;
    assertEquals(42, fourtytwo);
}
Also used : Message(org.jivesoftware.smack.packet.Message) JivePropertiesExtension(org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension) Test(org.junit.Test)

Example 5 with Message

use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.

the class MessageCorrectExtensionTest method checkStanzas.

@Test
public void checkStanzas() throws Exception {
    Message initialMessage = (Message) PacketParserUtils.parseStanza(initialMessageXml);
    MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage);
    Assert.assertEquals(messageCorrectExtension.toXML().toString(), messageCorrectionXml);
    initialMessage.addExtension(messageCorrectExtension);
    Assert.assertEquals(initialMessage.toXML(), expectedXml);
}
Also used : Message(org.jivesoftware.smack.packet.Message) MessageCorrectExtension(org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension) Test(org.junit.Test)

Aggregations

Message (org.jivesoftware.smack.packet.Message)142 Test (org.junit.Test)57 Presence (org.jivesoftware.smack.packet.Presence)17 StanzaCollector (org.jivesoftware.smack.StanzaCollector)14 MessageTypeFilter (org.jivesoftware.smack.filter.MessageTypeFilter)12 Stanza (org.jivesoftware.smack.packet.Stanza)12 XMPPException (org.jivesoftware.smack.XMPPException)11 XMPPConnection (org.jivesoftware.smack.XMPPConnection)9 Date (java.util.Date)8 MUCUser (org.jivesoftware.smackx.muc.packet.MUCUser)8 AccountItem (com.xabber.android.data.account.AccountItem)7 Chat (org.jivesoftware.smack.Chat)7 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)7 XmlPullParser (org.xmlpull.v1.XmlPullParser)7 ArrayList (java.util.ArrayList)6 Jid (org.jxmpp.jid.Jid)6 NetworkException (com.xabber.android.data.NetworkException)5 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)5 GeoLocation (org.jivesoftware.smackx.geoloc.packet.GeoLocation)5 IOException (java.io.IOException)4