2

I am implement group chat using xmpp jabber client. I am getting group creation successfully using below code.

 -(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!"];
}

So please suggest me a way how can i join user get list of existing group for further implementations.. Thanks,

BalKrishan Yadav
  • 467
  • 7
  • 21

2 Answers2

2

You can get the list of groups on you MUC server by this way using this 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];

}
Fatima Arshad
  • 350
  • 2
  • 5
  • Hello trying same code as per below url http://stackoverflow.com/questions/19268629/xmppframework-implement-group-chat-muc But i am not able to get room list which is already created. In delegate mthoed - (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq{} and how to handel responce in this methoed. – BalKrishan Yadav Sep 25 '14 at 10:15
  • 2
    I am able to get list of conference room sucessfully. But hw can i save this list in coredaatastorage of xmpp or parse for further use. or is there any way to handel list of groups for offline access. please share code or link which help me out of here... – BalKrishan Yadav Oct 05 '14 at 07:55
  • @BalKrishanYadav could you please include the code for getting group list. The above code doesn't work. – Augustin Jose Sep 19 '15 at 12:10
  • @BalKrishanYadav Can you please explain how you can get the group list? I have also tried but got nothing.Please help me. – Dipang Sep 08 '17 at 10:54
0
    let server: String = "conference.iamhosting"
    let servrJID: XMPPJID = XMPPJID.jidWithString(server)
    let iq: XMPPIQ = XMPPIQ.iqWithType("get", to: servrJID)
    iq.addAttributeWithName("id", stringValue: "chatroom_list")
    iq.addAttributeWithName("from", stringValue: stream.myJID.bare())
    let query = DDXMLElement.elementWithName("query")
    query.addAttributeWithName("xmlns", stringValue: "http://jabber.org/protocol/disco#items")
    iq.addChild(query as! DDXMLElement)
    stream.addDelegate(self, delegateQueue: dispatch_get_main_queue())
    stream.sendElement(iq)
Ga Ne Sh
  • 59
  • 9