XMPPFramework icon indicating copy to clipboard operation
XMPPFramework copied to clipboard

How to apply to join a private room?

Open huoda1237 opened this issue 1 year ago • 1 comments

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 avatar Jan 26 '24 07:01 huoda1237

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];

huoda1237 avatar Jan 26 '24 07:01 huoda1237