Objective c 成员无法在muc室中获取成员列表

Objective c 成员无法在muc室中获取成员列表,objective-c,xmpp,ejabberd,xmppframework,multiuserchat,Objective C,Xmpp,Ejabberd,Xmppframework,Multiuserchat,我正在为我们的聊天应用程序使用IOS XMPPFramework,我正在创建组并使用下面的代码添加所选成员,并且成功地加入了组。 如果我查询该组的成员列表,管理员成功检索该组的成员,但成员无法获得相同的列表,而是收到以下错误: <iq xmlns="jabber:client" from="250034370263@conference.chat.meeapps.com.tr" to="16503312600@chat.meeapps.com.tr/15323458207749806891

我正在为我们的聊天应用程序使用IOS XMPPFramework,我正在创建组并使用下面的代码添加所选成员,并且成功地加入了组。 如果我查询该组的成员列表,管理员成功检索该组的成员,但成员无法获得相同的列表,而是收到以下错误:

<iq xmlns="jabber:client" from="250034370263@conference.chat.meeapps.com.tr" to="16503312600@chat.meeapps.com.tr/15323458207749806891286" id="FF691FF5-D12B-4BAA-AB19-84E7A2B945D4" type="error"><query xmlns="http://jabber.org/protocol/muc#admin"><item affiliation="member"/></query><error code="403" type="auth"><forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Administrator privileges required</text></error></iq>
[编辑] 您还可以在以下xml中找到我的房间配置:

<?xml version="1.0" encoding="UTF-8"?>
<x xmlns="jabber:x:data" type="form">
   <title>Configuration of room 259297300263@conference.chat.meeapps.com.tr</title>
   <field type="hidden" var="FORM_TYPE">
      <value>http://jabber.org/protocol/muc#roomconfig</value>
   </field>
   <field type="text-single" label="Room title" var="muc#roomconfig_roomname">
      <value>osmannn</value>
   </field>
   <field type="text-single" label="Room description" var="muc#roomconfig_roomdesc">
      <value />
   </field>
   <field type="boolean" label="Make room persistent" var="muc#roomconfig_persistentroom">
      <value>1</value>
   </field>
   <field type="boolean" label="Make room public searchable" var="muc#roomconfig_publicroom">
      <value>1</value>
   </field>
   <field type="boolean" label="Make participants list public" var="public_list">
      <value>1</value>
   </field>
   <field type="boolean" label="Make room password protected" var="muc#roomconfig_passwordprotectedroom">
      <value>0</value>
   </field>
   <field type="text-private" label="Password" var="muc#roomconfig_roomsecret">
      <value />
   </field>
   <field type="list-single" label="Maximum Number of Occupants" var="muc#roomconfig_maxusers">
      <value>200</value>
      <option label="5">
         <value>5</value>
      </option>
      <option label="10">
         <value>10</value>
      </option>
      <option label="20">
         <value>20</value>
      </option>
      <option label="30">
         <value>30</value>
      </option>
      <option label="50">
         <value>50</value>
      </option>
      <option label="100">
         <value>100</value>
      </option>
      <option label="200">
         <value>200</value>
      </option>
   </field>
   <field type="list-single" label="Present real Jabber IDs to" var="muc#roomconfig_whois">
      <value>anyone</value>
      <option label="moderators only">
         <value>moderators</value>
      </option>
      <option label="anyone">
         <value>anyone</value>
      </option>
   </field>
   <field type="list-multi" label="Roles for which Presence is Broadcasted" var="muc#roomconfig_presencebroadcast">
      <value>moderator</value>
      <value>participant</value>
      <value>visitor</value>
      <option label="Moderator">
         <value>moderator</value>
      </option>
      <option label="Participant">
         <value>participant</value>
      </option>
      <option label="Visitor">
         <value>visitor</value>
      </option>
   </field>
   <field type="boolean" label="Make room members-only" var="muc#roomconfig_membersonly">
      <value>1</value>
   </field>
   <field type="boolean" label="Make room moderated" var="muc#roomconfig_moderatedroom">
      <value>1</value>
   </field>
   <field type="boolean" label="Default users as participants" var="members_by_default">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow users to change the subject" var="muc#roomconfig_changesubject">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow users to send private messages" var="allow_private_messages">
      <value>1</value>
   </field>
   <field type="list-single" label="Allow visitors to send private messages to" var="allow_private_messages_from_visitors">
      <value>anyone</value>
      <option label="nobody">
         <value>nobody</value>
      </option>
      <option label="moderators only">
         <value>moderators</value>
      </option>
      <option label="anyone">
         <value>anyone</value>
      </option>
   </field>
   <field type="boolean" label="Allow users to query other users" var="allow_query_users">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow users to send invites" var="muc#roomconfig_allowinvites">
      <value>0</value>
   </field>
   <field type="boolean" label="Allow visitors to send status text in presence updates" var="muc#roomconfig_allowvisitorstatus">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow visitors to change nickname" var="muc#roomconfig_allowvisitornickchange">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow visitors to send voice requests" var="muc#roomconfig_allowvoicerequests">
      <value>1</value>
   </field>
   <field type="boolean" label="Allow subscription" var="muc#roomconfig_allow_subscription">
      <value>1</value>
   </field>
   <field type="text-single" label="Minimum interval between voice requests (in seconds)" var="muc#roomconfig_voicerequestmininterval">
      <value>1800</value>
   </field>
   <field type="jid-multi" label="Exclude Jabber IDs from CAPTCHA challenge" var="muc#roomconfig_captcha_whitelist" />
</x>

在配置房间时,请确保将
muc#roomconfig_whois
设置为
any

 <field
          label='Who May Discover Real JIDs?'
          type='list-single'
          var='muc#roomconfig_whois'>
        <option label='Moderators Only'>
          <value>moderators</value>
        </option>
        <option label='Anyone'>
          <value>anyone</value>
        </option>
  </field>

主持人
任何人

[已编辑2]:

我想我得弄清楚出了什么问题。从代码中,首先邀请用户,然后将他们添加到成员中

你能试着倒过来吗。首先向成员添加所有,然后邀请。否则,当用户收到邀请时,可能尚未在Xmpp服务器上设置成员

以下是我所做的:

  • 加入文件室(如果文件室不存在,服务器将创建它)
  • 在xmppRoomDidCreate中,获取配置表单
  • 发送配置表单,然后立即添加所有成员
  • 在配置中,发送邀请
流程有点慢,我建议您将这些设置作为默认设置添加到mod_muc中。只需确保在发送邀请之前添加成员

[已编辑]:

这是我在配置文件室时的表格:

<x xmlns=\"jabber:x:data\" type=\"form\">
      <title>Configuration of room 1479231695@conference.192.168.100.226</title>
      <field type=\"hidden\" var=\"FORM_TYPE\">
        <value>http://jabber.org/protocol/muc#roomconfig</value>
      </field>
      <field type=\"text-single\" label=\"Room title\" var=\"muc#roomconfig_roomname\">
        <value></value>
      </field>
      <field type=\"text-single\" label=\"Room description\" var=\"muc#roomconfig_roomdesc\">
        <value></value>
      </field>
      <field type=\"boolean\" label=\"Make room persistent\" var=\"muc#roomconfig_persistentroom\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Make room public searchable\" var=\"muc#roomconfig_publicroom\">
        <value>0</value>
      </field>
      <field type=\"boolean\" label=\"Make participants list public\" var=\"public_list\">
        <value>0</value>
      </field>
      <field type=\"boolean\" label=\"Make room password protected\" var=\"muc#roomconfig_passwordprotectedroom\">
        <value>0</value>
      </field>
      <field type=\"text-private\" label=\"Password\" var=\"muc#roomconfig_roomsecret\">
        <value></value>
      </field>
      <field type=\"list-single\" label=\"Maximum Number of Occupants\" var=\"muc#roomconfig_maxusers\">
        <value>200</value>
        <option label=\"5\">
          <value>5</value>
        </option>
        <option label=\"10\">
          <value>10</value>
        </option>
        <option label=\"20\">
          <value>20</value>
        </option>
        <option label=\"30\">
          <value>30</value>
        </option>
        <option label=\"50\">
          <value>50</value>
        </option>
        <option label=\"100\">
          <value>100</value>
        </option>
        <option label=\"200\">
          <value>200</value>
        </option>
      </field>
      <field type=\"list-single\" label=\"Present real Jabber IDs to\" var=\"muc#roomconfig_whois\">
        <option label=\"moderators only\">
          <value>moderators</value>
        </option>
        <option label=\"anyone\">
          <value>anyone</value>
        </option>
        <value>anyone</value>
      </field>
      <field type=\"list-multi\" label=\"Roles for which Presence is Broadcasted\" var=\"muc#roomconfig_presencebroadcast\">
        <value>moderator</value>
        <value>participant</value>
        <value>visitor</value>
        <option label=\"Moderator\">
          <value>moderator</value>
        </option>
        <option label=\"Participant\">
          <value>participant</value>
        </option>
        <option label=\"Visitor\">
          <value>visitor</value>
        </option>
      </field>
      <field type=\"boolean\" label=\"Make room members-only\" var=\"muc#roomconfig_membersonly\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Make room moderated\" var=\"muc#roomconfig_moderatedroom\">
        <value>0</value>
      </field>
      <field type=\"boolean\" label=\"Default users as participants\" var=\"members_by_default\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow users to change the subject\" var=\"muc#roomconfig_changesubject\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow users to send private messages\" var=\"allow_private_messages\">
        <value>1</value>
      </field>
      <field type=\"list-single\" label=\"Allow visitors to send private messages to\" var=\"allow_private_messages_from_visitors\">
        <value>anyone</value>
        <option label=\"nobody\">
          <value>nobody</value>
        </option>
        <option label=\"moderators only\">
          <value>moderators</value>
        </option>
        <option label=\"anyone\">
          <value>anyone</value>
        </option>
      </field>
      <field type=\"boolean\" label=\"Allow users to query other users\" var=\"allow_query_users\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow users to send invites\" var=\"muc#roomconfig_allowinvites\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow visitors to send status text in presence updates\" var=\"muc#roomconfig_allowvisitorstatus\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow visitors to change nickname\" var=\"muc#roomconfig_allowvisitornickchange\">
        <value>1</value>
      </field>
      <field type=\"boolean\" label=\"Allow visitors to send voice requests\" var=\"muc#roomconfig_allowvoicerequests\">
        <value>1</value>
      </field>
      <field type=\"text-single\" label=\"Minimum interval between voice requests (in seconds)\" var=\"muc#roomconfig_voicerequestmininterval\">
        <value>1800</value>
      </field>
      <field type=\"jid-multi\" label=\"Exclude Jabber IDs from CAPTCHA challenge\" var=\"muc#roomconfig_captcha_whitelist\"></field>
    </x>

房间配置1479231695@conference.192.168.100.226
http://jabber.org/protocol/muc#roomconfig
1.
0
0
0
200
5.
10
20
30
50
100
200
主持人
任何人
任何人
调解人
参与者
游客
调解人
参与者
游客
1.
0
1.
1.
1.
任何人
没有人
主持人
任何人
1.
1.
1.
1.
1.
1800
如您所见,这些项目存在一些差异:

  • muc#roomconfig#U公共空间
  • 公营单位名单
  • muc#roomconfig#U moderatedroom
  • muc#roomconfig#u allowinvites

我试着将“muc#roomconfig_mediatedroom”设置为1,但所有成员都可以获得成员列表。不知道你那边发生了什么

让我在swift中添加我的工作代码,您可以检查是否有任何差异。对不起,我帮不了你

    func onButtonClicked(_ button: UIButton) {

        let roomJIDStr = theRoomJidStr // get the roomJid
        self.xmppRoom = joinRoom(with: roomJIDStr, delegate: self)
    }

    func joinRoom(with jidString: String, delegate: XMPPRoomDelegate) -> XMPPRoom {

        let roomJID = XMPPJID(string: jidString)
        let roomStorage = XMPPRoomCoreDataStorage.sharedInstance()

        let room = XMPPRoom(roomStorage: roomStorage, jid: roomJID, dispatchQueue: DispatchQueue.main)!

        room.activate(xmppStream)

        room.addDelegate(delegate, delegateQueue: DispatchQueue.main)

        room.join(usingNickname: xmppStream.myJID.user, history: nil)

        return room
    }

    public func xmppRoomDidCreate(_ sender: XMPPRoom!) {
        print("xmppRoomDidCreate")

        // Accept default settings
        let config = DDXMLElement(name: "x", xmlns: "jabber:x:data")
        sender.configureRoom(usingOptions: config)

        // Add members
        let query = DDXMLElement(name: "query", xmlns: XMPPMUCAdminNamespace)
        if let contacts = selectedContacts {

            for c in contacts {

                let item = DDXMLElement(name: "item")
                item.addAttribute(withName: "affiliation", stringValue: "member")
                item.addAttribute(withName: "jid", stringValue: c.xmppAccount!)

                query?.addChild(item)
            }
        }

        let id = XMPPStream.generateUUID()
        let to = sender.roomJID
        let iq = XMPPIQ(type: "set", to: to, elementID: id, child: query)

        chatManager.xmppStream.send(iq)
    }
先决条件:

  • 我将一些设置设置为mod_muc默认选项,因此不需要配置房间

     <field
              label='Who May Discover Real JIDs?'
              type='list-single'
              var='muc#roomconfig_whois'>
            <option label='Moderators Only'>
              <value>moderators</value>
            </option>
            <option label='Anyone'>
              <value>anyone</value>
            </option>
      </field>
    
    mod_muc:
    ##主持人:“会议。@主持人@”
    访问:
    -容许
    访问\u管理员:
    -允许:管理员
    访问创建:多创建
    持久访问:多个创建
    历史记录大小:0
    默认\u房间\u选项:
    允许用户邀请:true
    匿名:错
    默认情况下,成员:true
    仅限成员:正确
    主持人:错
    是的
    公众:错
    公共列表:错误

  • 我的代码中没有邀请,我直接将它们添加到成员列表中。并用于推送通知。当owner发送第一条消息时,所有其他成员将获得推送并开始获取成员列表


我对任何人都做了更改,但结果是一样的。你可以在编辑过的页面上看到我的配置xml真的很奇怪,也许你把所有相关的代码,从createRoom压缩到InviteUser,还有你的服务配置文件,然后分享给我,我会尽力弄清楚。永远不要了解您的问题。您可以在下面的链接中找到相关的代码部分:抱歉,文件中有错误。此链接中的最新文件:我发现了最新的问题,这是因为xmppframework pod文件已损坏,我重新生成了它并解决了问题,当然是按照您建议的实现了。现在我还有一个问题。当我获取成员列表时,我还获取版主列表,以显示谁是组管理员,服务器成功返回成员列表,但不返回版主列表,并给出所需的
版主权限的结果
如果所有者不发送任何消息,只创建房间,会发生什么?在这种情况下,接收者不知道创建的组,对吗?在我的应用程序中,仅当用户发送第一条消息时,才会创建聊天室。但你是对的,这取决于应用程序的行为。@tolgatanriverdi-你介意分享一下pod的问题是什么吗?我也有同样的问题(虽然我没有使用POD,但是直接集成了代码),但是对于正在发生的事情,我仍然会有所帮助。。。多谢。
    func onButtonClicked(_ button: UIButton) {

        let roomJIDStr = theRoomJidStr // get the roomJid
        self.xmppRoom = joinRoom(with: roomJIDStr, delegate: self)
    }

    func joinRoom(with jidString: String, delegate: XMPPRoomDelegate) -> XMPPRoom {

        let roomJID = XMPPJID(string: jidString)
        let roomStorage = XMPPRoomCoreDataStorage.sharedInstance()

        let room = XMPPRoom(roomStorage: roomStorage, jid: roomJID, dispatchQueue: DispatchQueue.main)!

        room.activate(xmppStream)

        room.addDelegate(delegate, delegateQueue: DispatchQueue.main)

        room.join(usingNickname: xmppStream.myJID.user, history: nil)

        return room
    }

    public func xmppRoomDidCreate(_ sender: XMPPRoom!) {
        print("xmppRoomDidCreate")

        // Accept default settings
        let config = DDXMLElement(name: "x", xmlns: "jabber:x:data")
        sender.configureRoom(usingOptions: config)

        // Add members
        let query = DDXMLElement(name: "query", xmlns: XMPPMUCAdminNamespace)
        if let contacts = selectedContacts {

            for c in contacts {

                let item = DDXMLElement(name: "item")
                item.addAttribute(withName: "affiliation", stringValue: "member")
                item.addAttribute(withName: "jid", stringValue: c.xmppAccount!)

                query?.addChild(item)
            }
        }

        let id = XMPPStream.generateUUID()
        let to = sender.roomJID
        let iq = XMPPIQ(type: "set", to: to, elementID: id, child: query)

        chatManager.xmppStream.send(iq)
    }