Создание многопользовательской группы с сервером Prosody на Android (aSmack) завершается сбоем из-за отсутствия подтверждения создания комнаты

Я работаю над приложением чата XMPP в Android, используя Prosody как XMPP server. Я написал код для создания комнаты Multi User Chat, и он отлично работает, когда я использую Openfire в качестве сервера, но когда я использую Prosody в качестве сервера, он дает мне ошибку, так как

Creation failed - Missing acknowledge of room creation.: т. е. группа уже существует. но он выдает ту же ошибку для любого имени (имя новой группы).

если я заменю muc.create(name); на muc.join(name);, он создаст группу. но тогда я не могу настроить свойства группы/комнаты.

ниже мой файл конфигурации Prosody: -

modules_enabled = {

-- Generally required
    "roster"; -- Allow users to have a roster. Recommended ;)
    "saslauth"; -- Authentication for clients and servers. Recommended if  you want to log in.
    --"tls"; -- Add support for secure TLS on c2s/s2s connections
    "dialback"; -- s2s dialback support
    "disco"; -- Service discovery

-- Not essential, but recommended
    "private"; -- Private XML storage (for room bookmarks, etc.)
    "vcard"; -- Allow users to set vCards

-- These are commented by default as they have a performance impact
    --"privacy"; -- Support privacy lists
    --"compression"; -- Stream compression

-- Nice to have
    "version"; -- Replies to server version requests
    "uptime"; -- Report how long server has been running
    "time"; -- Let others know the time here on this server
    "ping"; -- Replies to XMPP pings with pongs
    "pep"; -- Enables users to publish their mood, activity, playing music  and more
    "register"; -- Allow users to register on this server using a client  and change passwords

-- Admin interfaces
    "admin_adhoc"; -- Allows administration via an XMPP client that  supports ad-hoc commands
    --"admin_telnet"; -- Opens telnet console interface on localhost port  5582

-- HTTP modules
    "bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
    "http_files"; -- Serve static files from a directory over HTTP

-- Other specific functionality
    "groups"; -- Shared roster support
    --"announce"; -- Send announcement to all online users
    --"welcome"; -- Welcome users who register accounts
    --"watchregistrations"; -- Alert admins of registrations
    --"motd"; -- Send a message to users when they log in
    --"legacyauth"; -- Legacy authentication. Only used by some old  clients and bots.
};
 allow_registration = true -- Allow users to register new accounts

VirtualHost "localhost"

---Set up a MUC (multi-user chat) room server on conference.example.com:
Component "conference.localhost" "muc"

Мой код создания группы: -

                             MultiUserChat muc = new MultiUserChat(xmppConnection, room);

                          // Create the room
                          SmackConfiguration.setPacketReplyTimeout(2000);
                          String name = xmppConnection.getUser();
                          System.out.println("name:- " + name);
                          String name1 = name.substring(0, name.lastIndexOf("@"));
                          System.out.println("name1:- " + name1);
                          System.out.println("group name:- " + grpName);
                          muc.create(name1);

                          // Get the the room's configuration form
                          Form form = muc.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<FormField> fields = form.getFields(); fields.hasNext();) {
                              FormField field = (FormField) fields.next();

                              if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {
                                  // Sets the default value as the answer
                                  submitForm.setDefaultAnswer(field.getVariable());
                              }
                          }
                         // muc.sendConfigurationForm(submitForm);

                          Form f = new Form(Form.TYPE_SUBMIT);
                          try {
                               muc.sendConfigurationForm(f);
                          } catch (XMPPException xe) {
                               System.out.println( "Error on sendConfigurationForm:- " +  xe);
                          }

                          // Sets the new owner of the room
                          List<String> owners = new ArrayList<String>();
                          owners.add(xmppConnection.getUser());
                          submitForm.setAnswer("muc#roomconfig_roomowners", owners);
                          submitForm.setAnswer("muc#roomconfig_persistentroom", true);
                          muc.sendConfigurationForm(submitForm);

где я ошибаюсь?


person Yograj Shinde    schedule 05.09.2014    source источник
comment
Излишние отступы в java-коде затрудняют чтение, исправьте это.   -  person Flow    schedule 05.09.2014


Ответы (1)


Это вызвано нестандартным поведением плагина просодии MUC. По сути, он ведет себя так, как будто комната MUC уже существует, даже если это не так.

Вы должны возможности:

  • Использование Smack (начиная с версии 4.0) MultiUserChat.createOrJoin(String), в этом случае будет успешным. См. также SMACK-557.
  • Установка свойства prosody mod MUC с restrict_room_creation на true приведет к тому, что prosody будет вести себя так, как указано в XEP-45.

Поскольку вы хотите настроить комнату, единственным вариантом является изменение настройки просодии restrict_room_creation.

Обратите внимание, что есть еще одна проблема в коде Smack MUC, которая будет исправлена ​​в Smack 4.1 и вероятно, в просодии также будет реализован обходной путь. Но я не думаю, что этот вопрос здесь имеет отношение, информация просто для полноты картины.

person Flow    schedule 05.09.2014