use of org.bigbluebutton.freeswitch.voice.freeswitch.response.XMLResponseConferenceListParser in project bigbluebutton by bigbluebutton.
the class GetAllUsersCommand method handleResponse.
public void handleResponse(EslMessage response, ConferenceEventListener eventListener) {
//Test for Known Conference
String firstLine = response.getBodyLines().get(0);
if (!firstLine.startsWith("<?xml")) {
// System.out.println("Not XML: [{}]", firstLine);
return;
}
XMLResponseConferenceListParser confXML = new XMLResponseConferenceListParser();
//get a factory
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
//get a new instance of parser
SAXParser sp = spf.newSAXParser();
//Hack turning body lines back into string then to ByteStream.... BLAH!
String responseBody = StringUtils.join(response.getBodyLines(), "\n");
//http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html
//This Sux!
responseBody = responseBody.trim().replaceFirst("^([\\W]+)<", "<");
ByteArrayInputStream bs = new ByteArrayInputStream(responseBody.getBytes());
sp.parse(bs, confXML);
//Maybe move this to XMLResponseConferenceListParser, sendConfrenceEvents ?
VoiceUserJoinedEvent pj;
for (ConferenceMember member : confXML.getConferenceList()) {
//Foreach found member in conference create a JoinedEvent
String callerId = member.getCallerId();
String callerIdName = member.getCallerIdName();
String voiceUserId = callerIdName;
Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
if (matcher.matches()) {
voiceUserId = matcher.group(1).trim();
callerIdName = matcher.group(2).trim();
}
pj = new VoiceUserJoinedEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(), callerId, callerIdName, member.getMuted(), member.getSpeaking(), null);
eventListener.handleConferenceEvent(pj);
}
} catch (SAXException se) {
// System.out.println("Cannot parse repsonce. ", se);
} catch (ParserConfigurationException pce) {
// System.out.println("ParserConfigurationException. ", pce);
} catch (IOException ie) {
// System.out.println("Cannot parse repsonce. IO Exception. ", ie);
}
}
Aggregations