admin管理员组文章数量:1415139
Am using Strophe.js library for munication between my application with XMPP(Openfire) server.
I want add user with group, How can i create new group? How can i mention group name with add buddy query?
This is my code for adding new user
var str1=$pres({'xmlns':'jabber:client','from':[email protected],'to':[email protected],'type':'subscribe'}).c('nick',{'xmlns':''}).t(userName);
connection.send(str1.tree());
I refer XMPP extension over day but i cant find proper result
Am using Strophe.js library for munication between my application with XMPP(Openfire) server.
I want add user with group, How can i create new group? How can i mention group name with add buddy query?
This is my code for adding new user
var str1=$pres({'xmlns':'jabber:client','from':[email protected],'to':[email protected],'type':'subscribe'}).c('nick',{'xmlns':'http://jabber/protocol/nick'}).t(userName);
connection.send(str1.tree());
I refer XMPP extension over day but i cant find proper result
Share Improve this question edited Sep 14, 2016 at 12:02 Kenster 25.5k22 gold badges86 silver badges114 bronze badges asked Jan 11, 2012 at 9:24 Rajamohan SugumaranRajamohan Sugumaran 4,4994 gold badges24 silver badges19 bronze badges2 Answers
Reset to default 5You need to send a roster update. Read RFC 6121, Section 2 for details. You'll be sending this protocol:
<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>
With code something like:
$iq({'type':'set'}).c('query',{'xmlns':Strophe.NS.ROSTER})
.c('item', {'jid':'[email protected]','name':'nick'})
.c('group').t('My Group')
I have made this Using below code.
XMPPRoomCoreDataStorage *rosterstorage =[[XMPPRoomCoreDataStorage alloc] init]; XMPPRoom *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()];
Then
- (void)xmppRoomDidJoin:(XMPPRoom *)sender
{
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];
}
本文标签: javascripthow to create new group in xmpp serverStack Overflow
版权声明:本文标题:javascript - how to create new group in xmpp server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745197312a2647205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论