robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

How to apply to join a private room? #1237

Closed huoda1237 closed 9 months ago

huoda1237 commented 10 months ago

if i want to join a private room,and i know the roomJid,How can i join this room and be the memeber of this room?

thank you for your help

huoda1237 commented 10 months ago

when i use this method ,i can get this room's message,but if i want to fetch all room i joined,the result does not have this room, so , anyone can help me ?

join current private room:

XMPPJID roomJID = [XMPPJID jidWithString:roomJid]; XMPPRoom xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[XMPPRoomCoreDataStorage sharedInstance] jid:roomJID dispatchQueue:dispatch_get_main_queue()]; [xmppRoom activate:SDXmppManager.defaulManager.stream]; [xmppRoom joinRoomUsingNickname:@"apply to join" history:nil password:nil];

query all rooms i joined:

NSXMLElement queryElement= [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/disco#items"]; NSXMLElement iqElement = [NSXMLElement elementWithName:@"iq"]; [iqElement addAttributeWithName:@"type" stringValue:@"get"]; [iqElement addAttributeWithName:@"from" stringValue:SDXmppManager.defaulManager.stream.myJID.bare]; NSString *service = [NSString stringWithFormat:@"%@.%@",kSubDomain,kDomin]; [iqElement addAttributeWithName:@"to" stringValue:service]; [iqElement addAttributeWithName:@"id" stringValue:@"getMyRooms"]; [iqElement addChild:queryElement]; [SDXmppManager.defaulManager.stream sendElement:iqElement];