我正在使用 xmpp jabber 客户端实现群聊。我正在使用以下代码成功创建组。
-(void) CreateRoom {
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat"NewGroup@conference.%@",JABBER_DOMAIN_NAME]];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:appDelegate.xmppStream];
[xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:appDelegate.xmppStream.myJID.user
history:nil
password:nil];
}
- (void)xmppRoomDidCreateXMPPRoom *)sender
{
NSLog(@"xmppRoomDidCreate");
}
- (void)xmppRoomDidJoinXMPPRoom *)sender
{
NSLog(@"xmppRoomDidJoin");
[sender fetchConfigurationForm];
[sender inviteUser:[XMPPJID jidWithString"Test1"] withMessage"Greetings!"];
[sender inviteUser:[XMPPJID jidWithString"Test2"] withMessage"Greetings!"];
}
所以请建议我如何加入用户获取现有组的列表以进行进一步实现..
谢谢,
Best Answer-推荐答案 strong>
您可以使用 protocol: http://jabber.org/protocol/disco#items 以这种方式获取 MUC 服务器上的组列表。 :
- (void) getListOfGroups
{
XMPPJID *servrJID = [XMPPJID jidWithString:CONFERENCE_ROOM_SERVER];
XMPPIQ *iq = [XMPPIQ iqWithType"get" to:servrJID];
[iq addAttributeWithName"from" stringValue:[[self xmppStream] myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName"query"];
[query addAttributeWithName"xmlns" stringValue"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[[self xmppStream] sendElement:iq];
}
关于ios - 如何使用 xmpp ios 加入群组并获取现有群组的列表,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/26031185/
|