ios - 如何使用 xmpp ios 加入群组并获取现有群组的列表

标签 ios iphone xmpp chat xmppframework

我正在使用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)xmppRoomDidCreate:(XMPPRoom *)sender
{
 NSLog(@"xmppRoomDidCreate");
}
- (void)xmppRoomDidJoin:(XMPPRoom *)sender
{
NSLog(@"xmppRoomDidJoin");
[sender fetchConfigurationForm];

[sender inviteUser:[XMPPJID jidWithString:@"Test1"] withMessage:@"Greetings!"];
[sender inviteUser:[XMPPJID jidWithString:@"Test2"] withMessage:@"Greetings!"];
}

所以请建议我一种方法,我如何加入用户获取现有组的列表以进一步实现。 谢谢,

最佳答案

您可以使用此方式获取 MUC 服务器上的组列表 protocol: http://jabber.org/protocol/disco#items :

- (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/

相关文章:

ios - 在ios sdk中获取当月星期一的所有日期

ios - SQLITE 中的条件 INSERT 或 UPDATE

iphone - 我在 json 中发送字典,它有两个数组和多个值,但我收到响应访问被拒绝

java - openfire 外部组件如何处理存在和订阅?

python - 如何使用 python-xmpp 设置 Jabber 状态?

Node.js、XMPP Strope.js

ios - NSMutableArray 添加或删除

iphone - 如何控制 UISlider Value Changed-events 频率?

iphone - CVOpenGLESTextureCacheCreateTextureFromImage 返回 -6683(kCVReturnPixelBufferNotOpenGLCompatible)

ios - 在 iphone 中按日期对 NSDictionary 进行排序