Note that there are some explanatory texts on larger screens.

plurals
  1. POAccepting chatroom invitation
    text
    copied!<p>I'm able to create a MUC using XMPPFramework and send user invitation requests to join that room by using the code below.</p> <pre><code>// Creating AppDelegate *dele =(AppDelegate *) [[UIApplication sharedApplication]delegate]; xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:dele jid:[XMPPJID jidWithString:self.roomName] dispatchQueue:dispatch_get_main_queue()]; [xmppRoom addDelegate:dele delegateQueue:dispatch_get_main_queue()]; [xmppRoom activate:dele.xmppStream]; [xmppRoom joinRoomUsingNickname:self.myNick history:nil]; // Inviting [xmppRoom inviteUser:[XMPPJID jidWithString:@"abc@host"] withMessage:@"Come Join me"]; </code></pre> <p>How does a user "abc" know that he has received an invitation and how can he react to it either by accepting or declining?</p> <p>I could not find any class in XMPPFramework which directly deal with chat room invitation. My research says that whenever a user receives an chatroom invitation, xmmppStream's delegate method is called:</p> <pre><code>- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message </code></pre> <p>In that message, I check whether the it contains NSXMLElement with name "invite", and if it contains then i send a callback to the user. Then i create chatroom with the same name as the name of the chatroom from which user received invitation and enter that newly created room. It works fine but quiet lengthy and not quiet efficient. I want to know if there is a class in XMPPFramework available <a href="https://github.com/robbiehanson/XMPPFramework" rel="nofollow">here</a> which could handle chat room invitation separately. For instance, detecting, accepting, and declining of room invitations.</p> <p>My code for extracting room name:</p> <pre><code>- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message { NSXMLElement * x = [message elementForName:@"x" xmlns:XMPPMUCUserNamespace]; NSXMLElement * invite = [x elementForName:@"invite"]; NSXMLElement * decline = [x elementForName:@"decline"]; NSXMLElement * directInvite = [message elementForName:@"x" xmlns:@"jabber:x:conference"]; NSString *msg = [[message elementForName:@"body"]stringValue]; NSString *from = [[[message attributeForName:@"from"]stringValue]; if (invite || directInvite) { [self createAndEnterRoom:from Message:msg]; return; } [self.delegate newMessageRecieved:msg]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload