Search in sources :

Example 71 with Message

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

the class MultiUserChatManager method decline.

/**
     * Informs the sender of an invitation that the invitee declines the invitation. The rejection will be sent to the
     * room which in turn will forward the rejection to the inviter.
     *
     * @param room the room that sent the original invitation.
     * @param inviter the inviter of the declined invitation.
     * @param reason the reason why the invitee is declining the invitation.
     * @throws NotConnectedException
     * @throws InterruptedException 
     */
public void decline(EntityBareJid room, EntityBareJid inviter, String reason) throws NotConnectedException, InterruptedException {
    Message message = new Message(room);
    // Create the MUCUser packet that will include the rejection
    MUCUser mucUser = new MUCUser();
    MUCUser.Decline decline = new MUCUser.Decline(reason, inviter);
    mucUser.setDecline(decline);
    // Add the MUCUser packet that includes the rejection
    message.addExtension(mucUser);
    connection().sendStanza(message);
}
Also used : MUCUser(org.jivesoftware.smackx.muc.packet.MUCUser) Message(org.jivesoftware.smack.packet.Message)

Example 72 with Message

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

the class MultiUserChat method sendMessage.

/**
     * Sends a message to the chat room.
     *
     * @param text the text of the message to send.
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void sendMessage(String text) throws NotConnectedException, InterruptedException {
    Message message = createMessage();
    message.setBody(text);
    connection.sendStanza(message);
}
Also used : Message(org.jivesoftware.smack.packet.Message)

Example 73 with Message

use of org.jivesoftware.smack.packet.Message in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testSendMessageWithNullBody_ResposesHaveNoBody.

public void testSendMessageWithNullBody_ResposesHaveNoBody() throws Exception {
    //Thread.sleep(1000);
    myEvents.clear();
    Message baseMessage = myTransport.createBaseMessage(mySelf, null);
    myTransport.getFacade().getConnection().sendPacket(baseMessage);
    Thread.sleep(100);
    assertEquals("No events expected: " + myEvents, 0, myEvents.size());
}
Also used : TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage) Message(org.jivesoftware.smack.packet.Message)

Example 74 with Message

use of org.jivesoftware.smack.packet.Message in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testTimeIsSetInSimpleMessage.

public void testTimeIsSetInSimpleMessage() throws Throwable {
    Message baseMessage = myTransport.createBaseMessage(mySelf, "some text");
    myTransport.getFacade().getConnection().sendPacket(baseMessage);
    new WaitFor(TIMEOUT) {

        @Override
        protected boolean condition() {
            return myEvents.size() > 0;
        }
    };
    long diff = ((MessageEvent) myEvents.get(1)).getWhen().getTime() - System.currentTimeMillis();
    assertTrue("Time should be set for simple Jabber messages: " + diff, Math.abs(diff) < 150);
}
Also used : TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage) Message(org.jivesoftware.smack.packet.Message) WaitFor(jetbrains.communicator.util.WaitFor) MessageEvent(jetbrains.communicator.core.transport.MessageEvent)

Example 75 with Message

use of org.jivesoftware.smack.packet.Message in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testSimpleJabberMessage.

public void testSimpleJabberMessage() throws Throwable {
    Message message = new Message(mySelf.getName(), Message.Type.NORMAL);
    String body = "some текст <>#$%^";
    message.setThread("someThreadId");
    message.setBody(body);
    addEventListener();
    myFacade.getConnection().sendPacket(message);
    new WaitFor(TIMEOUT) {

        @Override
        protected boolean condition() {
            return myEvents.size() > 1;
        }
    };
    IDEtalkEvent event = myEvents.get(1);
    assertTrue("Expect message Event", event instanceof MessageEvent);
    assertEquals("Expect message text", body, ((MessageEvent) event).getMessage());
    assertEquals("Should remember threadId for incoming messages", "someThreadId", myTransport.getThreadId(mySelf));
}
Also used : TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage) Message(org.jivesoftware.smack.packet.Message) WaitFor(jetbrains.communicator.util.WaitFor) IDEtalkEvent(jetbrains.communicator.core.IDEtalkEvent) MessageEvent(jetbrains.communicator.core.transport.MessageEvent)

Aggregations

Message (org.jivesoftware.smack.packet.Message)166 Test (org.junit.Test)57 Presence (org.jivesoftware.smack.packet.Presence)21 XMPPException (org.jivesoftware.smack.XMPPException)15 StanzaCollector (org.jivesoftware.smack.StanzaCollector)14 NetworkException (com.xabber.android.data.NetworkException)13 Stanza (org.jivesoftware.smack.packet.Stanza)13 MUCUser (org.jivesoftware.smackx.muc.packet.MUCUser)13 MessageTypeFilter (org.jivesoftware.smack.filter.MessageTypeFilter)12 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)12 AccountItem (com.xabber.android.data.account.AccountItem)11 XMPPConnection (org.jivesoftware.smack.XMPPConnection)11 Date (java.util.Date)10 Jid (org.jxmpp.jid.Jid)10 Chat (org.jivesoftware.smack.Chat)9 AccountJid (com.xabber.android.data.entity.AccountJid)7 ArrayList (java.util.ArrayList)7 XmlPullParser (org.xmlpull.v1.XmlPullParser)7 InputStream (java.io.InputStream)6 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)6