Chat for Android

I need to create a chat / communication server for Android clients.

Android Android clients will be connected to the Internet via 3G or Wi-Fi. I need the following simple functions.

  • register a new user
  • send messages from one client to another.
  • will have approximately 500 clients connected at the same time

Based on the development of desktop applications, I mean only a socket-based solution and that the server should be a Java application

So the question is: does the socket approach work or should I use some other communication protocol.

+2
source share
2 answers

When using TCP sockets, this task will not be a good idea, since you will have to take care of many things, such as message formatting, streaming, etc. Use one of the available protocols and messaging libraries.

I would suggest looking into XMPP , which has a set of open standards for messaging between devices. The advantage is that there are many libraries for implementing both XMPP clients and servers.

To implement the XMPP client on Android devices, you can use the Smack library. This is actually a Java based library. I implemented the Facebook XMPP chat client using Asmack , which is Smack's Android port. The Smack documentation is also applicable to Asmack. However, Asmack has not been updated for two years and has some problems, and I thought about changing my client to Smack to find out if the new version works well with Android.

Regarding the implementation of the XMPP server, you can check out Openfire made by the same guys who made Smack. I have not used this yet, but there is extensive documentation on setting up Openfire on the project page. Judging by the quality of the Smack library I used, I believe that Openfire will work just fine.

Good luck

+6
source

It does not matter what the other end of the server is written on, because HTTP is a high-level protocol. In fact, you'll probably end up using sockets if you don't do something about GCM . Outlets are a heavy battery, and you probably only want to maintain a socket at the same time to check for updates on the chat server at a certain rate proportional to the use of the application. Also remember that you cannot maintain a network connection in the main thread, and you can usually access it through a service.

0
source

All Articles