QXmpp 在服务器上创建 MUC 房间 (xep--0045)

QXmpp creating a MUC room (xep--0045) on the server

我正在尝试使用 QXmpp 向我的应用程序添加 MUC 功能,我在 QXmppMucManager.h 头文件

中关注此信息
/// \brief The QXmppMucManager class makes it possible to interact with
/// multi-user chat rooms as defined by XEP-0045: Multi-User Chat.
///
/// To make use of this manager, you need to instantiate it and load it into
/// the QXmppClient instance as follows:
///
/// \code
/// QXmppMucManager *manager = new QXmppMucManager;
/// client->addExtension(manager);
/// \endcode
///
/// You can then join a room as follows:
///
/// \code
/// QXmppMucRoom *room = manager->addRoom("room@conference.example.com");
/// room->setNickName("mynick");
/// room->join();
/// \endcode
///
/// \ingroup Managers

在我的 类 之一的构造函数中,我添加了一个像这样的 MuCManager

QXmppMucManager *manager = new QXmppMucManager;

    m_xmppClient.addExtension(manager);

并在创建 Muc 组的插槽中我正在这样做

QXmppMucRoom *room = manager->addRoom("livefit@mthinkpad");

    room->setNickName("mThinkpad");

    room->join();

我希望这能创建一个房间,如果它不存在就加入,如果它已经存在就加入,但它只是崩溃我的application.I无法理解 qxmpp 如何实现 xep- -0045.I 如果有人帮助指出我做错了什么或如何从我的客户端在我的服务器上创建 Muc 房间,我将不胜感激。 我的服务器是本地 ejabberd 安装,我可以在 "mthinkpad" 域访问它。

万一有人遇到同样的问题,我能够创建 rooms.Here 是 that.I 即时创建和配置房间的代码(我使用的是 Openfire,它允许它),但如果需要,您可以索取配置表。

String jid=roomName.text()+"@conference."+serverName;
       if(jid.isEmpty())
               return ;
           QList<QXmppMucRoom*> rooms = manager->rooms();
           QXmppMucRoom* r;
           foreach(r, rooms)
           {
               if(r->jid() == jid)
               {
                   //LOG_MODEL_DEBUG("Group chat", "had joined room[%s]", qPrintable(jid));
                   return ;
               }
           }
           m_pRoom = manager->addRoom(jid);
           if(m_pRoom)
           {
               //nick
               m_pRoom->setNickName("theDip");
               //join the room.
               m_pRoom->join();
           }

           //Prepare the dataform.
           QXmppDataForm form(QXmppDataForm::Submit);
           QList<QXmppDataForm::Field> fields;
           {
               QXmppDataForm::Field field(QXmppDataForm::Field::HiddenField);
               field.setKey("FORM_TYPE");
               field.setValue("http://jabber.org/protocol/muc#roomconfig");
               fields.append(field);
           }
           QXmppDataForm::Field field;
           field.setKey("muc#roomconfig_roomname");
           field.setValue(roomName.text());
           fields.append(field);

           field.setKey("muc#roomconfig_subject");
           field.setValue(roomSubject.text());
           fields.append(field);

           field.setKey("muc#roomconfig_roomdesc");
           field.setValue(roomDesc.text());
           fields.append(field);
           {
               QXmppDataForm::Field field(QXmppDataForm::Field::BooleanField);
               field.setKey("muc#roomconfig_persistentroom");
               field.setValue(true);
               fields.append(field);
           }

           form.setFields(fields);
           //The dataform ends here.
           m_pRoom->setConfiguration(form);