Near-company projects require instant messaging. After investigation, we found that openfire + spark + smack can be implemented. I have been searching online for a long time and the materials are very limited. Even if some of my friends have done so, I am not clear about it. So I decided to study it myself, and it took a week to implement the function of text communication and file transmission. I am posting to share my post with anyone who needs it. I hope you can share all your materials with me.
Enough nonsense. Now let's get started:
1. What is openfire?
Openfire is an instant messaging server, also known as the instant messaging platform. It is based on the XMPP protocol and is familiar with communication software QQ, MSN and Gtalk. Gtalk is based on the implementation of XMPP protocol.
In instant messaging, you often do not need to use point-to-point communication because you need to save some status or data. Instead, you need to build a server for forwarding.
: Http://www.igniterealtime.org/downloads/index.jsp
After the download is complete, install and configure as prompted, and then access port 9090 on the configured server address to access the openfire background management system officially implemented for us.
2. What is Spark?
Spark is essentially a Java program running on a PC. You can think of it as an official client running on a PC for us. We only need to download and use it.
(Of course, if the current Spark project requirement cannot be met, you can download the Spark Source code from the official website and modify it)
: Http://www.igniterealtime.org/downloads/index.jsp
3. What is smack?
Smack can be considered as a encapsulated API for implementing XMPP protocol transmission. It is a very simple and powerful class library, and only three lines of code are required to send messages to users.
: Http://www.igniterealtime.org/downloads/index.jsp
Here, we need to emphasize that we are actually using the transplanted version of the class library asmack on Android, And the versions that asmack is circulating online now have bugs, a null pointer exception is reported during file transmission. I am also the most time-consuming on this issue. I have found many versions that have been modified by some netizens on the Internet, but I have finally found a reliable asmack revision in the EOE Forum:
See: http://www.eoeandroid.com/thread-186418-1-1.html
Openfire + spark + smack for instant messaging