Xmpp login to register a friend group _ practical tutorial 4, xmpp login Registration

Source: Internet
Author: User
Tags call back

Xmpp login to register a friend group _ practical tutorial 4, xmpp login Registration

// Obtain the status of friends-online or offline. Just write it for judgment and return.

. H

 1 /*! 2  *  @Author Dylan. 3  * 4  *  Paresence 5  */ 6 typedef void (^userGoOnline) (NSString *); 7 typedef void (^userGoOffline) (NSString *); 8  9 - (void)refreshRosterPresence: (userGoOnline)online10                       offline: (userGoOffline)offline;

. M

 1 #pragma mark presence 2 - (void)refreshRosterPresence: (userGoOnline)online 3                       offline: (userGoOffline)offline { 4      5     self.rosterOnline = online; 6     self.rosterOffline = offline; 7 } 8  9 - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {10     11     // get presence type12     NSString * presenceType = [presence type];13     NSString * userID = [[sender myJID] user];14     15     NSString * presencrFromUser = [[presence from] user];16     if (![presencrFromUser isEqualToString:userID]) {17         if ([presenceType isEqualToString:@"available"]) {18             self.rosterOnline(presencrFromUser);19         } else if ([presenceType isEqualToString:@"unavailable"]) {20             self.rosterOffline(presencrFromUser);21         }22     }23 }

Add Block and Return Statement

1 /*!2  *  call back block3  */4 @property (nonatomic, copy) userGoOnline rosterOnline;5 @property (nonatomic, copy) userGoOffline rosterOffline;

 




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.