Search in sources :

Example 1 with MUCLightCreateIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ in project Smack by igniterealtime.

the class MultiUserChatLight method create.

/**
     * Create new MUCLight.
     * 
     * @param roomName
     * @param subject
     * @param customConfigs
     * @param occupants
     * @throws Exception
     */
public void create(String roomName, String subject, HashMap<String, String> customConfigs, List<Jid> occupants) throws Exception {
    MUCLightCreateIQ createMUCLightIQ = new MUCLightCreateIQ(room, roomName, occupants);
    messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter);
    try {
        connection.createStanzaCollectorAndSend(createMUCLightIQ).nextResultOrThrow();
    } catch (NotConnectedException | InterruptedException | NoResponseException | XMPPErrorException e) {
        removeConnectionCallbacks();
        throw e;
    }
}
Also used : XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) MUCLightCreateIQ(org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ)

Example 2 with MUCLightCreateIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ in project Smack by igniterealtime.

the class MUCLightCreateIQTest method checkCreateMUCLightStanza.

@Test
public void checkCreateMUCLightStanza() throws Exception {
    List<Jid> occupants = new ArrayList<>();
    occupants.add(JidCreate.from("charlie@test.com"));
    occupants.add(JidCreate.from("pep@test.com"));
    MUCLightCreateIQ mucLightCreateIQ = new MUCLightCreateIQ(JidCreate.from("ef498f55-5f79-4238-a5ae-4efe19cbe617@muclight.test.com").asEntityJidIfPossible(), "test", occupants);
    mucLightCreateIQ.setStanzaId("1c72W-50");
    Assert.assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test");
    HashMap<Jid, MUCLightAffiliation> iqOccupants = mucLightCreateIQ.getOccupants();
    Assert.assertEquals(iqOccupants.get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
    Assert.assertEquals(iqOccupants.get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
}
Also used : Jid(org.jxmpp.jid.Jid) ArrayList(java.util.ArrayList) MUCLightCreateIQ(org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ) Test(org.junit.Test)

Aggregations

MUCLightCreateIQ (org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ)2 ArrayList (java.util.ArrayList)1 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)1 Test (org.junit.Test)1 Jid (org.jxmpp.jid.Jid)1