use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.
the class MUCLightAffiliationsChangeExtensionTest method checkAffiliationsChangeExtension.
@Test
public void checkAffiliationsChangeExtension() throws Exception {
Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanza);
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension.from(changeAffiliationsMessage);
HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
Assert.assertEquals(affiliations.size(), 3);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
}
use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.
the class MUCLightConfigurationsChangeExtensionTest method checkRoomNameChangeExtension.
@Test
public void checkRoomNameChangeExtension() throws Exception {
Message configurationsMessage = (Message) PacketParserUtils.parseStanza(messageWithRoomNameChangeExample);
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension.from(configurationsMessage);
Assert.assertEquals("zaqwsx", configurationsChangeExtension.getPrevVersion());
Assert.assertEquals("zxcvbnm", configurationsChangeExtension.getVersion());
Assert.assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
Assert.assertNull(configurationsChangeExtension.getSubject());
Assert.assertNull(configurationsChangeExtension.getCustomConfigs());
Assert.assertEquals(messageWithRoomNameChangeExample, configurationsMessage.toXML().toString());
}
use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.
the class GeoLocationManager method sendGeoLocationToJid.
public void sendGeoLocationToJid(GeoLocation geoLocation, Jid jid) throws InterruptedException, NotConnectedException {
final XMPPConnection connection = connection();
Message geoLocationMessage = new Message(jid);
geoLocationMessage.addExtension(geoLocation);
connection.sendStanza(geoLocationMessage);
}
use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.
the class MultiUserChat method requestVoice.
/**
* Sends a voice request to the MUC. The room moderators usually need to approve this request.
*
* @throws NotConnectedException
* @throws InterruptedException
* @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">XEP-45 ยง 7.13 Requesting
* Voice</a>
* @since 4.1
*/
public void requestVoice() throws NotConnectedException, InterruptedException {
DataForm form = new DataForm(DataForm.Type.submit);
FormField formTypeField = new FormField(FormField.FORM_TYPE);
formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request");
form.addField(formTypeField);
FormField requestVoiceField = new FormField("muc#role");
requestVoiceField.setType(FormField.Type.text_single);
requestVoiceField.setLabel("Requested role");
requestVoiceField.addValue("participant");
form.addField(requestVoiceField);
Message message = new Message(room);
message.addExtension(form);
connection.sendStanza(message);
}
use of org.jivesoftware.smack.packet.Message in project Smack by igniterealtime.
the class ChatStateManager method setCurrentState.
/**
* Sets the current state of the provided chat. This method will send an empty bodied Message
* stanza(/packet) with the state attached as a {@link org.jivesoftware.smack.packet.ExtensionElement}, if
* and only if the new chat state is different than the last state.
*
* @param newState the new state of the chat
* @param chat the chat.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void setCurrentState(ChatState newState, org.jivesoftware.smack.chat.Chat chat) throws NotConnectedException, InterruptedException {
if (chat == null || newState == null) {
throw new IllegalArgumentException("Arguments cannot be null.");
}
if (!updateChatState(chat, newState)) {
return;
}
Message message = new Message();
ChatStateExtension extension = new ChatStateExtension(newState);
message.addExtension(extension);
chat.sendMessage(message);
}
Aggregations