Original address: xmppframework iOS development (6) chat room
Chat Room
// Initialize the chat room principal * roomjid = [xmppjid jidwithstring: room_jid]; xmpproom = [[xmpproom alloc] Principal: Self jid: roomjid]; [xmpproom activate: xmppstream [xmpproom adddelegate: Self delegatequeue: dispatch_get_main_queue ()];
// Join the chat room and use the nickname [xmpproom joinroomusingnickname: @ "quack" History: Nil];
// Obtain the chat room information-(void) Configure :( xmpproom *) sender {[xmpproom fetchconfigurationform]; [xmpproom fetchbanlist]; [xmpproom fetchmemberslist]; [xmpproom submit];}
If the room exists, the delegate is called.
// Receive prohibition list-(void) xmpproom :( xmpproom *) sender didfetchbanlist :( nsarray *) items; // receive a friend list-(void) xmpproom :( xmpproom *) sender didfetchmemberslist :( nsarray *) items; // receives the host list-(void) xmpproom :( xmpproom *) sender didfetchmoderatorslist :( nsarray *) items;
The specified room does not exist. The delegate is called.
- (void)xmppRoom:(XMPPRoom *)sender didNotFetchBanList:(XMPPIQ *)iqError; - (void)xmppRoom:(XMPPRoom *)sender didNotFetchMembersList:(XMPPIQ *)iqError; - (void)xmppRoom:(XMPPRoom *)sender didNotFetchModeratorsList:(XMPPIQ *)iqError;
Leave room
[xmppRoom deactivate:xmppStream];