use of org.jivesoftware.smack.packet.MessageBuilder in project Smack by igniterealtime.
the class StableUniqueStanzaIdTest method fromMessageTest.
@Test
public void fromMessageTest() {
MessageBuilder messageBuilder = StanzaBuilder.buildMessage();
Message message = messageBuilder.build();
assertFalse(OriginIdElement.hasOriginId(message));
assertFalse(StanzaIdElement.hasStanzaId(message));
OriginIdElement.addTo(messageBuilder);
message = messageBuilder.build();
assertTrue(OriginIdElement.hasOriginId(message));
StanzaIdElement stanzaId = new StanzaIdElement("alice@wonderland.lit");
message.addExtension(stanzaId);
assertTrue(StanzaIdElement.hasStanzaId(message));
assertEquals(stanzaId, StanzaIdElement.getStanzaId(message));
}
use of org.jivesoftware.smack.packet.MessageBuilder 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 if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void decline(EntityBareJid room, EntityBareJid inviter, String reason) throws NotConnectedException, InterruptedException {
XMPPConnection connection = connection();
MessageBuilder messageBuilder = connection.getStanzaFactory().buildMessageStanza().to(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
messageBuilder.addExtension(mucUser);
connection.sendStanza(messageBuilder.build());
}
use of org.jivesoftware.smack.packet.MessageBuilder 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 if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void sendMessage(String text) throws NotConnectedException, InterruptedException {
MessageBuilder message = StanzaBuilder.buildMessage().setBody(text);
sendMessage(message);
}
use of org.jivesoftware.smack.packet.MessageBuilder in project Smack by igniterealtime.
the class ChatConnectionTest method validateMessageTypeWithDefaults1.
@Test
public void validateMessageTypeWithDefaults1() {
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Message.Type.chat);
processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat());
}
use of org.jivesoftware.smack.packet.MessageBuilder in project Smack by igniterealtime.
the class ChatConnectionTest method chatNotMatchedWithTypeNormal.
@Test
public void chatNotMatchedWithTypeNormal() {
cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket(null, false);
incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build());
assertNull(listener.getNewChat());
}
Aggregations