0

I am developing chat application for one to one chat and group chat.

I have successfully done one to one chat.

Using the below link I have created Group chat.

Link to create Group chat in smack 4.2.0-beta1

I can see the group in admin panel but There is only a single user available, But I have created this group with three members. Here I have added my code.

 public void createGroupChat() {

        String DomainName = "conference."+ServiceAddress;
        // Create a MultiUserChat using a Connection for a room
// Get the MultiUserChatManager
        MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
        try {
            EntityBareJid jid = JidCreate.entityBareFrom("mychatroom3" + "@"
                    + DomainName);

// Create a MultiUserChat using an XMPPConnection for a room
            MultiUserChat muc = manager.getMultiUserChat(jid);

// Prepare a list of owners of the new room
            Set<Jid> owners = JidUtil.jidSetFrom(new String[]{"admin" + "@"
                    + DomainName, "dev1" + "@"
                    + DomainName, "dev2" + "@"
                    + DomainName});

// Create the room
            Resourcepart nickname = Resourcepart.from("admin");
            muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();
            muc.join(nickname);
            Log.e("Group chat", "Created");
            Toast.makeText(context,
                    "Group chat" + "Created",
                    Toast.LENGTH_SHORT).show();
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucAlreadyJoinedException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MissingMucCreationAcknowledgeException e) {
            e.printStackTrace();
        } catch (NotConnectedException e) {
            e.printStackTrace();
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.NotAMucServiceException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucConfigurationNotSupportedException e) {
            e.printStackTrace();
        }
    }

Exception that I got

08-01 05:58:14.589 917-917/com.agarangroup.hello W/System.err: org.jivesoftware.smackx.muc.MultiUserChatException$MucConfigurationNotSupportedException: The MUC configuration 'muc#roomconfig_roomowners' is not supported by the MUC service
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at org.jivesoftware.smackx.muc.MucConfigFormManager.setRoomOwners(MucConfigFormManager.java:137)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.Services.MyXMPP.createGroupChat(MyXMPP.java:331)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.slidingtab.chats.GroupChatActivity.onCreate(GroupChatActivity.java:99)
MathankumarK
  • 2,717
  • 1
  • 17
  • 34

1 Answers1

2

There are 2 cases: 1) Your conference service does not supports owners (depends by server, Ejabber in your case, and this doesn't sounds normal)

2) Your config form it's not completed as documentation says and you need to create a full form.

How to fix: substitute this line:

 muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();

with:

muc.create(nickname);
Form form = muc.getConfigurationForm().createAnswerForm();
form.setAnswer("muc#roomconfig_roomowners", owners);
muc.sendConfigurationForm(form); 

pay attention to names:

your DomainName it's the Service conference name + Server Domain Name. An owner can be a JID (foo@myserver) and not related on service (so foo@service.myserver it's not a valid user, even if server will accept it).

Fix your owners with:

"admin" + "@" + ServiceAddress, "dev1" + "@" + ServiceAddress, "dev2" + "@" + ServiceAddress
MrPk
  • 2,862
  • 2
  • 20
  • 26
  • I have another doubt, I cannot create new user it says "Forbidden auth" In server configuration I provided Registration allow all. But it doesn't work. Can you tell me why I am getting this error? @MrPk – MathankumarK Aug 02 '16 at 05:34
  • hard to reply in a comment, open another question and be sure to describe the use case (client, case and method). If you have problem with Spark probably you miss the server name, if you have problem with java code I have to check – MrPk Aug 02 '16 at 08:26
  • Thank you. Hai, I have created new question here I have added the link http://stackoverflow.com/questions/38718282/creating-new-user-with-smack-4-2-0-beta1-on-ejabberd-throws-xmpp-exception-forb – MathankumarK Aug 02 '16 at 10:47
  • I am getting error using above code.form.setAnswer("muc#roomconfig_roomowners", owners); says 'Couldn't find a field for the specified variable.' Can you hep me? @MrPk – D G Sep 26 '18 at 07:15
  • At moment I can't get any check, you need to verificate by yourself what is the equivalent of "muc#roomconfig_roomowners", maybe new versions of Smack just changed the name of this flag. It's everytime possible to retreive full names of params asking for empty form. Hope that helps. @D G – MrPk Sep 26 '18 at 07:35