Android XMPP-based instant messaging app

Source: Internet
Author: User

XMPP is a communication protocol. Because this is an open agreement, many real-time applications use this protocol in order to economize on development costs. The most commonly used combination of Android Asmack +openfire. Asmack is the Android version of Smack, which encapsulates the XMPP protocol and provides a rich API that simplifies operations. OpenFire is an open source IM server, based on XMPP implementations. In other words, using XMPP to develop instant messaging applications, the server side has been developed, that is, OpenFire.

Now I'm doing an Android app that uses Asmack+openfire. To be honest, the XMPP protocol is too much, mostly English, to learn the cost of this thing is high, but if you do not learn, relying solely on the functions provided by Openfire+asmack is difficult to meet the needs of diversity. OpenFire because it is open source, it can do plug-in development or two development to meet their business needs. XMPP also added the Jingle Extension protocol to support connection-oriented business, such as voice and video.

The most typical example of previous industry xmpp is Google Talk, and Google has been pushing the XMPP protocol before. But Google's latest IM software hangouts did not use the XMPP protocol, and Google did not have a clear answer to this practice. Google's approach does reduce the heat of XMPP. Many people say that XMPP transmission efficiency is low, XMPP uses XML format data to communicate, too many tags can indeed reduce transmission efficiency. And now the mainstream of the domestic IM software, QQ, and so on, are using their own private communications protocol. OpenFire uses the TCP connection, QQ uses the TCP+UDP.

is to develop their own protocols, whether to use the XMPP protocol, or the packaged XMPP Protocol (SMACK) + off-the-shelf server (openfire) is everyone's decision. But the three options are reduced in turn, and the cost is reduced in turn. The budget of our project is relatively low, so we adopted asmack+openfire. But what I'm going to say here is that relying solely on asmack+openfire is not enough to meet the needs of the general business. So our project introduced WebService, while trying to develop plug-ins for OpenFire.

Here I can talk about some of the asmack+openfire development encountered in the weak places, such as:

Users cannot accept offline pictures, voice.

Group members will leave the group after they are offline (in other words, smack no group concept, only a chat room)

Group chat There is no way to send pictures (Point-to-point when the picture is sent using a file transfer, only one-off, not one-to-many)

Other questions are not in detail. For the above questions, you will share your solution in subsequent articles.

The biggest advantage of XMPP is that it seems to me to be open source. This open source allows any two software that uses the XMPP protocol to communicate.

It is necessary to understand some of the data structures of XMPP before development. An XMPP connection uses an XML stream that is equivalent to an envelope for all XML sections during a session

  |--------------------|  | <stream>           |  | --------------------|  | <presence>         |  |   <show/>          |  | </presence>        |  | --------------------|  | <message to= ' foo ' > |  |   <body/>          |  | </message>         |  | --------------------|  | <iq to= ' Bar >      |  |   <query/>         |  | </iq>              |  | --------------------|  | ...                |  | --------------------|  | </stream>          |  | --------------------|

Several nodes in presence, message, and IQ correspond to the 3 objects of Asmack. These are the subclasses of the packet.

On the Asmack API, no separate Asmack API was found, and no Chinese. You can download the jar package and choose to download the source code. Eclipse refers to the source code, through the Javadoc can see the interface description, and API is the same.

Asmack Official website: https://github.com/Flowdalic/asmack

asmack:http://asmack.freakempire.de/

openfire:http://www.igniterealtime.org/downloads/index.jsp

Smack User Guide: http://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.html

Download OpenFire at the same time, you can download spark test

Update 2015-3-12

Now smack (more than 4.1) has been able to run directly on the Android platform, and later Asmack is not necessary to update. This time smack did a lot of optimizations for the Android platform and smack a milestone update.

In addition, the design of the use of Openfire+smack+webservice may be a more excellent solution. In other words, only use smack communication function, such as friend relationship, user profile These things are handed to webservice to manage maintenance.

Smack Reference: Https://community.igniterealtime.org/blogs/ignite/2015/01/14/smack-410-beta1-available

Android XMPP-based instant messaging app

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.