我正在研究MUC,因为我想将用户加入书签。因为我已经使用了xep-0048扩展,并且作为服务器文档显示我已经创建了相同的iq请求但似乎书签不起作用。
Folloing是我的iq请求
<iq type="set" id="pip1" from="jid@server.local">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish node="storage:bookmarks">
<item id="current">
<storage xmlns="storage:bookmarks">
<conference name="roomExample1" autojoin="true" jid="roomExample1@conference.server.local">
<nick>satish</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="pubsub#persist_items">
<value>true</value>
</field>
<field var="pubsub#access_model">
<value>whitelist</value>
</field>
</x>
</publish-options>
</pubsub>
</iq>
当我将此请求发送到服务器时,我从服务器获得以下响应。
<iq xmlns="jabber:client" from="jid@server.local" to="jid@server.local/14748802401387269663600179" id="pip1" type="result">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish node="storage:bookmarks">
<item id="current"/>
</publish>
</pubsub>
</iq>
当我发送iq请求以检索书签时,我也得到相同的响应。
如果我遗失任何内容,请告诉我。
提前致谢。
答案 0 :(得分:1)
使用此功能发送请求
[xmppStream sendElement:iq];
并按如下所示创建您的iqbookmark对象
NSString* server = @"test@pc"; //or whatever the server address for muc is
XMPPJID *servrJID = [XMPPJID jidWithString:server];
XMPPIQ *iq = [XMPPIQ iqWithType:@"set" to:servrJID];
// [iq addAttributeWithName:@"from" stringValue:[xmppStream myJID].full];
[iq addAttributeWithName:@"id" stringValue:@"123"];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"jabber:iq:private"];
NSXMLElement *storage_q = [NSXMLElement elementWithName:@"storage"];
[storage_q addAttributeWithName:@"xmlns" stringValue:@"storage:bookmarks"];
NSXMLElement *conference_s = [NSXMLElement elementWithName:@"conference"];
[conference_s addAttributeWithName:@"name" stringValue:@"roomExample1_satish"];
[conference_s addAttributeWithName:@"autojoin" stringValue:@"true"];
[conference_s addAttributeWithName:@"jid" stringValue:@"roomExample1@conference.test@pc"];
[conference_s addAttributeWithName:@"nick" stringValue:@"satish"];
[storage_q addChild:conference_s];
[query addChild:storage_q];
[iq addChild:query];