Android的聊天服务器

Android的聊天服务器

本文介绍了Android的聊天服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建基于Android的客户端聊天/通讯服务器。

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

Android的聊天客户端将通过3G或WiFi网络连接到互联网
我需要以下简单的特点

The android chat clients will be connected to internet via 3g or wifi networkI need following simple features


  • 注册一个新用户

  • 从一个客户端发送消息到另一个

  • 将有大约500个客户端同时连接

从桌面应用程序开发的到来,我只有基于Socket的解决方案在我的头脑和服务器应该是一个基于Java的应用程序

Coming from desktop app development, I only have socket based solution in my mind and that the server should be a java based application

所以,问题是:是套接字基础的方法可行,或者我应该使用一些其他的通信协议

So the question is : Is the socket based approach workable or should I use some other communication protocol.

推荐答案

在使用TCP套接字将做的工作,这不是一个好主意,因为你将不得不采取的东西很多照顾,比如邮件格式,流媒体,等使用的已有消息协议和库之一。

While using TCP sockets will do the job, it's not a good idea as you would have to take care of a LOT of stuff, like message formatting, streaming, etc. Use one of the already available messaging protocols and libraries.

我会建议寻找到,其中有一组开放标准用于设备间执行消息传递。一个优点是,有大量的库可用于实现既XMPP客户端和服务器。

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

有关实施在Android设备上的XMPP客户端,您可以使用一个名为库。它实际上是一个基于Java库。我已经实现了使用 Facebook的XMPP聊天客户端,这是一款Android端口咂嘴。该啪文档适用于Asmack为好。然而,Asmack一直没有更新了两年,并有一些问题,我一直在想改变我的客户嫌,看看新版本中起着很好的与Android的。

For implementing an XMPP client on Android devices, you can use a library called Smack. It is actually a Java based library. I have implemented a Facebook XMPP chat client using Asmack, which is a Android port of Smack. The Smack documentation is applicable to Asmack as well. However, Asmack hasn't been updated for two years and has some issues and I've been thinking of changing my client to Smack to see if the new version plays nice with Android.

对于实现一个XMPP服务器,你可以检查出,取得通过谁做拍击相同的家伙。我没有用过这个还没有,但该项目页面对设置的Openfire大量的文档。由我用拍击库的质量来看,我敢说的Openfire将工作pretty很好。

As for implementing an XMPP server, you can check out Openfire, made by the same guys who made Smack. I have not used this yet, but the project page has extensive documentation on setting up Openfire. Judging by the quality of the Smack library which I used, I daresay Openfire will work pretty well.

祝你好运!

这篇关于Android的聊天服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:45