我正在使用 xmpp ejabberd 开发聊天应用程序。我想开发一个类似于 whats 应用程序的 XMPP 群聊。XMPP 群聊设置是在我的 XMPP 服务器上完成的。我正在成功创建房间并加入房间。但我想要我加入的房间。我正在使用以下 iq 从服务器获取组列表
NSString* server = @"conference.test.com";
XMPPJID *serverJID = [XMPPJID jidWithString:server];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:serverJID];
[iq addAttributeWithName:@"from" stringValue:[[APP_DELEGATE xmppStream] myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[[APP_DELEGATE xmppStream] sendElement:iq];
从上面的代码中,我从我的服务器获取组列表,但我想要我加入的组列表或我收到邀请的组。
创建和加入房间的代码如下
-(void) CreateRoom:(NSString *)roomJid {
static dispatch_once_t queueCreationGuard;
static dispatch_queue_t queue;
dispatch_once(&queueCreationGuard, ^{
queue = dispatch_queue_create("com.something.myapp.backgroundQueue", 0);
});
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPJID *roomJID = [XMPPJID jidWithString:roomJid];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage jid:roomJID dispatchQueue:queue];
[xmppRoom activate:[self xmppStream]];
[xmppRoom addDelegate:self
delegateQueue:queue];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"0"];
[xmppRoom joinRoomUsingNickname:[self xmppStream].myJID.user
history:history
password:nil];
}
- (void)xmppRoomDidCreate:(XMPPRoom *)sender
{
NSLog(@"Room Created");
}
- (void)xmppRoomDidJoin:(XMPPRoom *)sender
{
NSLog(@"Room Joined");
}
如果有人有解决方案,请回答问题。谢谢