use of org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ in project Smack by igniterealtime.
the class MUCLightInfoTest method checkMUCLightInfoResult.
@Test
public void checkMUCLightInfoResult() throws Exception {
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(exampleInfoResult);
MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) iqInfoResult;
Assert.assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
Assert.assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().size(), 3);
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("john@test.com")), MUCLightAffiliation.owner);
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
}
use of org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ in project Smack by igniterealtime.
the class MultiUserChatLight method getFullInfo.
/**
* Get the MUC Light info.
*
* @param version
* @return the room info
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
* @throws InterruptedException
*/
public MUCLightRoomInfo getFullInfo(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow();
MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq;
return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room, mucLightInfoResponseIQ.getConfiguration(), mucLightInfoResponseIQ.getOccupants());
}
use of org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ in project Smack by igniterealtime.
the class MUCLightInfoIQProvider method parse.
@Override
public MUCLightInfoIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
String version = null;
String roomName = null;
String subject = null;
HashMap<String, String> customConfigs = null;
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("version")) {
version = parser.nextText();
}
if (parser.getName().equals("configuration")) {
int depth = parser.getDepth();
outerloop2: while (true) {
eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("roomname")) {
roomName = parser.nextText();
} else if (parser.getName().equals("subject")) {
subject = parser.nextText();
} else {
if (customConfigs == null) {
customConfigs = new HashMap<>();
}
customConfigs.put(parser.getName(), parser.nextText());
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getDepth() == depth) {
break outerloop2;
}
}
}
}
if (parser.getName().equals("occupants")) {
occupants = iterateOccupants(parser);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getDepth() == initialDepth) {
break outerloop;
}
}
}
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
}
Aggregations