}
public void startConference(String roomName, String server,
List<String> users, String reason) {
// Create a MultiUserChat using a Connection for a room
MultiUserChat muc = new MultiUserChat(connection, roomName + "@"
+ server);
PacketListener myListener = new PacketListener() {
@Override
public void processPacket(Packet packet) {
//System.out.println("PacketData:" + packet.toXML());
if (packet.getClass().toString().equalsIgnoreCase(
"class org.jivesoftware.smack.packet.Message")) {
Message m = (Message) packet;
if (m.getBody() != null) {
// System.out.println("Body is " + m.getBody());
DelayInformation inf = null;
try {
inf = (DelayInformation) packet.getExtension(
"x", "jabber:x:delay");
String[] username = m.getFrom().split("/");
String t[] = username[0].split("@");
if (t.length >= 2) {
System.out.println("Room:" + t[0] + ",msg:" + m.getBody() + ",User:" + username[1]);
sendToConfPage(t[0], m.getBody(), username[1], t[1]);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
};
muc.addMessageListener(myListener);
PacketListener peopleListener = new PacketListener() {
@Override
public void processPacket(Packet packet) {
//System.out.println("People PacketData:" + packet.toXML());
if (packet.getClass().toString().equalsIgnoreCase(
"class org.jivesoftware.smack.packet.Presence")) {
Presence p = (Presence) packet;
try {
System.out.println("Presence from: " + p.getFrom());
System.out.println("Presence :" + p.toString());
String[] username = p.getFrom().split("/");
String t[] = username[0].split("@");
//System.out.println("Room:"+t[0]+",msg:"+m.getBody()+",User:"+username[1]);
if (p.toString().equalsIgnoreCase("available")) {
sendToConfPage(t[0], "** '" + username[1] + "' joined the room **", "", t[1]);
} else if (p.toString().equalsIgnoreCase("unavailable")) {
sendToConfPage(t[0], "** '" + username[1] + "' left the room **", "", t[1]);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
muc.addParticipantListener(peopleListener);
try {
// Create the room
//System.out.println(muc);
muc.create(chatRoom);
// Send an empty room configuration form which indicates that we
// want
// an instant room
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
for (String user : users) {
muc.invite(user, reason);
}
System.out.println("Created Chat Room :" + roomName + " with " + users);
myChatRooms.add(muc);
} catch (XMPPException e) {