XMPP书签的自动加入选项不起作用 [英] Autojoin option of xmpp bookmark does not work

查看:68
本文介绍了XMPP书签的自动加入选项不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用XEP-0048自动加入会议室-书签( http://xmpp .org/extensions/xep-0048.html ).

I am trying to auto-join rooms using XEP-0048 - Bookmarks (http://xmpp.org/extensions/xep-0048.html).

我正在使用RobbieHanson XMPPFramework,ejabberd v13.x 到目前为止,我已经可以使用以下代码向房间添加书签:

I am using RobbieHanson XMPPFramework, ejabberd v13.x So far, I have been able to add bookmark to the room using the following code :

-(void) createBookmarkforRoom:(NSString *)roomJid {
    NSXMLElement *nick = [NSXMLElement elementWithName:@"nick" stringValue:@"Marge"];

    NSXMLElement *conference = [DDXMLNode elementWithName:@"conference"];
    [conference addAttributeWithName:@"name" stringValue:@"BookmarkName"];
    [conference addAttributeWithName:@"autojoin" stringValue:@"true"];
    [conference addAttributeWithName:@"jid" stringValue:roomJid];

    [conference addChild:nick];

    NSXMLElement *storage =[DDXMLNode elementWithName:@"storage"];
    [storage addAttributeWithName:@"xmlns" stringValue:@"storage:bookmarks"];

    [storage addChild:conference];

    NSDictionary *options = [NSDictionary dictionaryWithObjects:@[@"pubsub#persist_items",@"pubsub#access_model"]
                                                    forKeys:@[@"true",@"whitelist"]];

    [self.publishSubscribeModule publishToNode:@"storage:bookmarks"
                                     entry:(NSXMLElement *)storage
                                withItemID:(NSString *)@"current"
                                   options:(NSDictionary *)options];

}

以下xml已成功发送:

The following xml is successfully sent :

<iq type="set" id="2749368B-E365-45D6-A4B0-2F79DC6F4747">
   <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <publish node="storage:bookmarks">
         <item id="current">
            <storage xmlns="storage:bookmarks">
               <conference name="BookmarkName" autojoin="true" jid="testroom@conference.mydomain.com">
                  <nick>Marge</nick>
               </conference>
            </storage>
         </item>
      </publish>
      <publish-options>
         <x xmlns="jabber:x:data" type="submit">
            <field var="FORM_TYPE" type="hidden">
               <value>http://jabber.org/protocol/pubsub#publish-options</value>
            </field>
            <field var="true">
               <value>pubsub#persist_items</value>
            </field>
            <field var="whitelist">
               <value>pubsub#access_model</value>
            </field>
         </x>
      </publish-options>
   </pubsub>
</iq>

我收到:

<iq xmlns="jabber:client" from="marge@mydomain.com" to="marge@mydomain.com/41045582821403862604272126" id="2749368B-E365-45D6-A4B0-2F79DC6F4747" type="result">
   <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <publish node="storage:bookmarks">
         <item id="current" />
      </publish>
   </pubsub>
</iq>

当我尝试使用以下代码获取书签时:

When I try to fetch bookmarks using the following code :

-(void)requestBookmarks {
    DDXMLElement *pubsub = [DDXMLElement elementWithName:@"pubsub" xmlns:@"http://jabber.org/protocol/pubsub"];

    DDXMLElement *items = [DDXMLElement elementWithName:@"items"];
    [items addAttributeWithName:@"node" stringValue:@"storage:bookmarks"];

    [pubsub addChild:items];

    XMPPIQ *iqBookmark = [XMPPIQ iqWithType:@"get" elementID:@"retrievebookmark10" child:pubsub];
    [self.stream sendElement:iqBookmark];
}

它发送以下xml:

<iq type="get" id="retrievebookmark10">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
        <items node="storage:bookmarks"/>
    </pubsub>
</iq>

我收到:

<iq xmlns="jabber:client" from="marge@mydomain.com" to="marge@mydomain.com/41045582821403862604272126" id="retrievebookmark10" type="result">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
        <items node="storage:bookmarks">
            <item id="current">
                <storage xmlns="storage:bookmarks">
                    <conference name="BookmarkName" autojoin="true" jid="testroom@conference.mydomain.com">
                        <nick>Marge</nick>
                    </conference>
                </storage>
            </item>
        </items>
    </pubsub>
</iq>

因此,看来我可以成功存储书签并对其进行检索.但是,当我尝试在会议室testroom@conference.mydomain.com中讲话而没有手动加入时,我收到一条错误消息,说我必须先加入会议室,然后才能在会议室中讲话.如果我(手动)加入房间,那么一切都很好.

So it seems that I can successfully store bookmarks and retrieve them. But, when I try to talk in the room testroom@conference.mydomain.com without manually joining it I get a error saying that I have to join the room before I can talk in the room. If I join the room (manually), every things works fine.

在服务器端,我使用了具有以下选项的mod_pubsub模块:

On the server-side, I used the mod_pubsub module with the following options :

  mod_pubsub:
   access_createnode: pubsub_createnode
    ## reduces resource comsumption, but XEP incompliant
   ignore_pep_from_offline: true
    ## XEP compliant, but increases resource comsumption
    ## ignore_pep_from_offline: false
   last_item_cache: false
   plugins:
     - "flat"
     - "hometree"
     - "pep" # pep requires mod_caps

我想知道为什么我必须手动加入带有"auto-join = true"房间的书签.有什么线索吗?

I am wondering why do I have to manually join bookmarked with "auto-join = true" rooms. Any clue ?

推荐答案

自动加入书签的房间完全是客户端功能-客户端应该在启动时检索书签,并显式加入标记为自动加入"的房间.

Autojoining bookmarked rooms is entirely a client-side feature - the client is supposed to retrieve the bookmarks at startup, and explicitly join the rooms marked as "auto-join".

这篇关于XMPP书签的自动加入选项不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆