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);
}
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);
}
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());
}
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);
}
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));
}
Aggregations