powered by Jive Software

Create password protected multiuserchat

I’'m looking for an example how to create a password protected multiuserchat. Simple mucs to create works well.



This example will work given that user4 is already created via the admin console.

I am still struglling with creating a room if create a user with via the api AccountManager? I must be missing a property in the form which I am still trying to figure out.

public void createMUC1() {

try {

// Create MultiUserChat for conference room EncrypedID.

muc1_cust = new MultiUserChat(xmppConnection, this.encryptedID + “@conference.localhost”);


// Get the the room’'s configuration form

Form form = muc1_cust.getConfigurationForm();

// Create a new form to submit based on the original form

Form submitForm = form.createAnswerForm();

// Add default answers to the form to submit

for (Iterator fields = form.getFields(); fields.hasNext():wink: {

FormField field = (FormField) fields.next();

if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {

// Sets the default value as the answer

//System.out.println(“Setting field.getVariable()” + field.getVariable());




// Overide defaults.

submitForm.setAnswer(“muc#roomconfig_roomname”, this.encryptedID);

submitForm.setAnswer(“muc#roomconfig_roomsecret”, jiveUserPassword);

submitForm.setAnswer(“muc#roomconfig_publicroom”, false);

submitForm.setAnswer(“muc#roomconfig_passwordprotectedroom”, true);

// Sets the new owner of the room

List owners = new ArrayList();

owners.add(this.encryptedID + “_SND@localhost”); // Smack

owners.add(this.encryptedID + “_REC@localhost”); // Xiff

// owners.add(“user3@localhost”);



owners.add(“user2@localhost”); // Spark IM for monitoring

owners.add(“userAA@localhost”); // Spark IM for monitoring

submitForm.setAnswer(“muc#roomconfig_roomowners”, owners);


PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class),

new FromContainsFilter("@conference.localhost"));

PacketListener myListener = new PacketListener() {

public void processPacket(Packet packet) {

// Do something with the incoming packet here.

System.out.println(“processPacket reached”);

System.out.println(“MUC1 packet.toXML:” + packet.toXML());



// Register room listener


// Register the listener.

xmppConnection.addPacketListener(myListener, filter);

} catch (XMPPException gg) {

System.out.println("\n\n[ERROR:] - XMPP *** Server ERROR: " + gg + “\n\n”);