XMPP Query Group Chat (MUC) directory using search term

帅比萌擦擦* 提交于 2019-12-11 04:56:23

问题


Creating an XMPP client, part of which involves querying the directory for chat rooms whose name matches a specific search term. Lets call this search term SEARCH.

The following XML (with the correct to/from) gives me a list of all chat rooms.

<iq from='hag66@shakespeare.lit/pda' id='disco2' to='chat.shakespeare.lit' type='get'>
      <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>

example result:

<iq xmlns="jabber:client" type="result" id="disco2" from="chat.shakespeare.lit" to="hag66@shakespeare.lit/pda">
    <query xmlns="http://jabber.org/protocol/disco#items">
        <item jid="example@shakespeare.lit" name="Example"/>
    </query>
</iq>

However, I need to query only chat rooms that match a specific term. Looking at the XMPP XML syntax, it looks like one of these XML queries should work:

<iq type="get" from="hag66@shakespeare.lit/pda" to="chat.shakespeare.lit" id="disco2">
    <query xmlns="jabber:iq:search">
        <x xmlns="jabber:x:data" type="get">
            <field var="name">
                <value>*SEARCH*</value>
            </field>
        </x>
    </query>
</iq>

Or this:

<iq type="set" from="hag66@shakespeare.lit/pda" to="chat.shakespeare.lit" id="search2">
    <query xmlns="jabber:iq:search">
        <item name="*SEARCH*"/>
    </query>
</iq>

I have tried switching "get" to "set" and vice versa. I have also tried removing the wildcard and making a literal search for a room I know exists.

Does anyone have an idea what the correct syntax is for searching for one or multiple names (Wildcarded) in the same query from the XMPP MUC service?

EDIT: My XMPP server supports the following features for the group chat service

<iq xmlns="jabber:client" type="result" from="chat.shakespeare.lit" to="hag66@shakespeare.lit/pda">
    <query xmlns="http://jabber.org/protocol/disco#info">
        <identity category="conference" name="Public Chatrooms" type="text"/>
        <identity category="directory" name="Public Chatroom Search" type="chatroom"/>
        <feature var="http://jabber.org/protocol/muc"/>
        <feature var="http://jabber.org/protocol/disco#info"/>
        <feature var="http://jabber.org/protocol/disco#items"/>
        <feature var="jabber:iq:search"/>
        <feature var="http://jabber.org/protocol/rsm"/>
    </query>
</iq>

Any ideas? Anyone? I would settle for a way of getting a list of chat rooms that I have created?

来源:https://stackoverflow.com/questions/9133166/xmpp-query-group-chat-muc-directory-using-search-term

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!