In the previous few, we discussed the environment configuration, the framework of the import and user login, this one we say friend module.
Before we get to the point, let's start debugging.
First, open the preferences to see if the OpenFire server and MySQL open, remember to open MySQL first, then open OpenFire, then, click Open Admin conconsole,
The following page appears, and it succeeds.
Enter the user name and password, login, this interface appears:
Then, click "Users/Groups" on the navigation bar, the management of users and chat groups appears.
We can see that there are two users, one is the administrator, one is the ordinary user Zhangsan, we click on the left menu, create a new user Wangwu, login password 123456.
On a Mac, there's an app called info, click on it. and select Add account in the menu bar
Select a different "info" account and click Continue.
Click Login, successfully connected, we can go back to the OpenFire console and discover that Zhang San is already logged in.
This is successful, we can use the program and Zhang San Chat.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////
Next is the topic of today, Buddy module.
In the previous method of setting up the module, we added the friend module and activated it.
//Buddy ModuleSelf.xmpproster =[[Xmpproster alloc] initwithrosterstorage:[xmpprostercoredatastorage sharedinstance]]; //do not automatically agree to a friend request[Self.xmpproster Setautoacceptknownpresencesubscriptionrequests:no]; [Self.xmpproster Setautoclearallusersandresources:no]; //do not sync friends list automatically once login is complete[Self.xmpproster Setautofetchroster:no]; //Friends Chat Recording moduleSelf.xmppmessagearchiving =[[Xmppmessagearchiving alloc] Initwithmessagearchivingstorage:[xmppmessagearchivingcoredatastorage Sharedinstance]]; //Activate[Self.xmpproster Activate:self.xmppStream]; [Self.xmppmessagearchiving Activate:self.xmppStream];
We can use the following proxy method to get a friend's upper and lower line notification:
-(void) Xmppstream: (Xmppstream *) sender Didreceivepresence: (xmpppresence *) Presence { // This if set up when stating that the other wants to subscribe you if ([Presence.type isequaltostring:@ "Subscribe " ]) { [Self.xmpproster acceptpresencesubscriptionrequestfrom:presence. from Andaddtoroster:yes];} }
Received a presence message, of course, we do not have a friend on-line operation, the current code means to receive a friend subscription request, and agree.
-(void) AddUser: (Xmppjid *) Jid withnickname: (NSString *) optionalname;
The function of the above code is to send a request to add a friend. Then, the other party in the above agent received a subscription message, choose to agree or pop-up friend's request.
Next, let's talk about the buddy list module.
iOS Development--xmppframework--Buddy module (iv)