2012-01-11 3 views
4

私のアプリケーションとXMPP(Openfire)サーバーとの通信にStrophe.jsライブラリを使用しています。xmppサーバーで新しいグループを作成する方法

グループに追加するグループ、 新しいグループを作成するにはどうすればよいですか? 追加のバディークエリでグループ名をどのように言及できますか?

は、これは私が一日かけてXMPPの拡張を参照してくださいしかし、私はあなたには、名簿の更新を送信する必要があり、適切な結果

答えて

5

を見つけるカント

var str1=$pres({'xmlns':'jabber:client','from':[email protected],'to':[email protected],'type':'subscribe'}).c('nick',{'xmlns':'http://jabber.org/protocol/nick'}).t(userName); 
connection.send(str1.tree()); 

新しいユーザー

を追加するための私のコードです。詳細は Read RFC 6121, Section 2をご覧ください。私はコードの下に使用し、これを作った

$iq({'type':'set'}).c('query',{'xmlns':Strophe.NS.ROSTER}) 
    .c('item', {'jid':'[email protected]','name':'nick'}) 
     .c('group').t('My Group') 
+1

海ジョーは、最初に私はその後のみ、拡張子がこの –

+2

を提供しますどのなものとして可能。ありません、新しいグループを作成したいですベースXMPPの空のグループ。おそらくPEP(XEP-0163:http://xmpp.org/extensions/xep-0163.html)を使用して空のグループのリストを個別に保存することも、そのプライベートストレージ(XEP-0049:http:// xmpp.org/extensions/xep-0049.html)。いずれの場合も、管理する新しい名前空間を使用しますが、他のクライアントが空のグループを参照できるようにすることはできません。これについて強く感じたら、新しいXEPを書いてXSFに提出してください:http://xmpp.org/xmpp-protocols/xmpp-extensions/submitting-a-xep/ –

0

:のようなコードの何かを

<iq from='[email protected]/balcony' 
    id='rs1' 
    type='set'> 
    <query xmlns='jabber:iq:roster'> 
    <item jid='[email protected]' name='nick'> 
     <group>My Group</group> 
    </item>   
    </query> 
</iq> 

:あなたはこのプロトコルを送ることになります。

XMPPRoomCoreDataStorage * rosterstorage = [[XMPPRoomCoreDataStorage alloc] init]; XMPPRoom * [XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@ "[email protected]"] dispatchQueue:dispatch_get_main_queue()];

[xmppRoom activate:[[self appDelegate]xmppStream]]; 
[xmppRoom joinRoomUsingNickname:@"DeveloperQ" history:nil]; 

[[[self appDelegate] xmppStream] addDelegate:self delegateQueue:dispatch_get_main_queue()]; 
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()]; 

そして

  • (ボイド)xmppRoomDidJoin:(XMPPRoom *)送信者

{

NSXMLElement *のIQ = [NSXMLElement elementWithName: "IQ" @]。私は特定のグループにユーザーを追加カントこの場合には

[iq addAttributeWithName:@"id" stringValue:[NSString stringWithFormat:@"inroom-cr%@",groupName]]; 
[iq addAttributeWithName:@"to" stringValue::@"[email protected]"]; 
[iq addAttributeWithName:@"type" stringValue:@"set"]; 
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:XMPPMUCOwnerNamespaceName]; 
NSXMLElement *xelem = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"]; 
[xelem addAttributeWithName:@"type" stringValue:@"submit"]; 
[query addChild:xelem]; 
[iq addChild:query]; 
[[[self appDelegate] xmppStream] sendElement:iq]; 

}

関連する問題