XMPP (ii)-Introduction and personal experience of Android client (imitation QQ) based on Asmack+openfire

Source: Internet
Author: User
Tags web database

about XMPP The first-openfire of the building after writing, has been in this article to introduce the Asmack+openfire based on the Android client, a lot of energy, because there are many students in the anxiously waiting for (narcissism of hehe), so tight to slow rush, Now to make a relatively basic version, a lot of features are not perfect, but first put out, for everyone to reference research, ask questions, study together, of course, the project I will continue to improve, add new features, even to later groups, interested, we can continue to focus on ^-^

OK, now let's introduce the following features of this project:

1. Registration;

2. Login;

3. Find people by nickname;

4. Add a friend (send a friend request, the other party receives the friend requests, and agrees, can become friends);

5. Interface, including recent contacts, friends list, etc.;

6. Chat: Currently supported types have text, pictures, location, dynamic expression, etc. (here to illustrate, in this primary version, the path and location of the image coordinates are fixed );

7. Exit;

8. Do not log in; (Once login is successful, the next time you start the software automatically login);

Interface:


Part of the feature on the interface This version is not implemented, as well as some details of the processing, code optimization, etc. will be gradually improved, and sent out in a future blog.

Next, the chat mode opened, in fact, pure this for chatting and the app is not many, in addition to our familiar QQ, and so on, other social applications are basically will chat this piece into the app, and this QQ-style add friends and so on in today's social applications are also usually converted to concern, be concerned about or fans, etc. , such as relatively well-known micro-BO, Mo Mo, and so on, not well-known that more went. Because XMPP this piece, chat with each other does not need both sides must be a friend relationship, just know each other's Jid can send and receive messages, therefore, many applications are also just fancy this point, to realize the application of concern, fans and other functions, and attention, cancel attention, pull black and other functions can be achieved through the Web services, And XMPP at this time only as a point-to-point chat function, so you do not have to tangle with XMPP itself with the invitation of friends, agree to friends apply, get friends list and so on, just a general understanding can, focus on the implementation of the chat process, as well as the client-to-server connection stability (such as how to reconnect, XMPP comes with a heavy connection is not stable) and so on, of course, if some students are very strong spirit, or the company has needs, then you can go into the deep research.

      Support XMPP protocol has a lot of service side, more familiar is OpenFire, and when a project really decided to use openfire as a server , want to achieve more complex points of the function or meet their own requirements of the function, all need to change the OpenFire, because OpenFire has certain limitations, but fortunately it is open source, in addition, the general social software if the use of OpenFire, there are two server, one is their own web server, one is OpenFire server, like Friends Avatar, nickname, gender, age, address, And such information data as Mo Mo's photo wall can be accessed through Web services, only the Web database and the user ID of the database can correspond, and only rely on the openfire itself, the access to these data is not possible. To do this project, the intention of the web and of the combination, to achieve more complex and close to the actual combat function, but finally gave up, should be so much work, I do not have so many energy and time, hehe! So, as mentioned above, we can focus on chatting, and how to use the vast amount of information stored on the Web to combine with the, that's the point! (--personal view)

Okay, now let's talk about the chat process, film, voice, video and other information how through the XMPP transmission, I also often encountered a classmate came up to ask, xmpp how to voice ah, how to preach files ah such (but now XMPP seems to support file transfer, specifically did not try), in fact, As long as we think seriously, we can think of a solution, what is the quickest and easiest way to pass the XMPP? Of course it's a string! What can be in a string? Anything can have! Therefore, we can put the information we want into the string to transmit the past, the other side received the message, parse it, you can get everything you want to get things, such as this project, pictures, and the implementation of location messages, is to send the past (for example: Receiver * sender * Message type * message content * Send time *) to the body of the message with the receiver and the sender's information at a specific spacer interval and assembled into a string. And so on), the other side received the message with "*" split will be able to get all the information, not fast? Therefore, for the picture voice video and other types of information, we only need its path, then how to get the path? As I said above, with the Web service, now upload the picture voice and so on to the Web server to get the path after the successful upload (this is not difficult), and then send the path as a string to the other side, the recipient receives the message by message type resolution, and according to the path to download pictures or voice ... Specific reference to the implementation of the project process!

Well, let's talk about it first, there is time to continue this blog, the project will continue to update!

Project Source: http://download.csdn.net/detail/baiyuliang2013/8391863

Note: After the source deployment, find Consts.java in the xmpp_host, need to modify their own IP address (the name of the best with the native IP, specifically can see the article--openfire Installation and build), Another: The client is to the service side that is openfire supported, if not installed on the end is not run up.




XMPP (ii)-Introduction and personal experience of Android client (imitation QQ) based on Asmack+openfire

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.