Accepting chatroom invitation

后端 未结 2 1287
死守一世寂寞
死守一世寂寞 2020-12-13 22:40

I\'m able to create a MUC using XMPPFramework and send user invitation requests to join that room by using the code below.

// Creating
AppDelegate *dele =(Ap         


        
相关标签:
2条回答
  • 2020-12-13 23:00

    just add below code

    if  ([presenceType isEqualToString:@"subscribe"]) {
    
         [_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"localhost"]];
         NSLog(@"presence user wants to subscribe %@",presenceFromUser);
    
         [xmppRoster acceptPresenceSubscriptionRequestFrom:[presence from] andAddToRoster:YES];
    
     //For reject button
    //     [xmppRoster rejectPresenceSubscriptionRequestFrom:[tmpPresence from]];          
    }
    

    inside the method

     - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence ;
    method
    
    0 讨论(0)
  • 2020-12-13 23:03

    For room invitations and declines, implement XMPPMUCDelegate and its methods -xmppMUC:didReceiveRoomInvitation: and -xmppMUC:didReceiveRoomInvitationDecline:.

    To get the room JID, invoke [message from];

    To join the room, instantiate an XMPPRoom and invoke -joinRoomUsingNickname:history:.

    Then have your room delegate class implement XMPPRoomDelegate, and implement some of the delegate methods to handle receiving messages in the room.

    It looks like there isn't at present a more automatic way to respond to invitations.

    Update: The delegate callbacks now receive the room JID as a parameter, clarifying the semantics a bit.

    - (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *) roomJID didReceiveInvitation:(XMPPMessage *)message;
    - (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *) roomJID didReceiveInvitationDecline:(XMPPMessage *)message;
    
    0 讨论(0)
提交回复
热议问题