iPhone / Android的实时通信,XMPP,原始TCP?实时、原始、通信、iPhone

2023-09-07 09:25:14 作者:把我推进深海你真善良

我有一个应用程序有2个版本:1,在iPhone上,1在Android

I have an app that has 2 versions : 1 on iPhone, 1 on Android.

我希望我的2应用程序来进行实时通信。用例是:

I want my 2 apps to communicate in real time. The use cases are :

用户A看到好友列表,选择一个用户B,然后点击共享项目 用户B收到通知说,用户A的广域网与他分享的项目 用户B接受,该交易发生,无一不通知用户,它顺利。

User A sees a friends list, pick a user B and click on "share an item" User B get a notification saying that user A wans to share an item with him User B accepts, the transaction takes place, and both users are notified that it goes well.

我想过使用一个简单的HTTP事务,但会投票给用户,因此没有一个很好的用户体验。

I thought about using a simple HTTP transaction, but that would polling for the user therefore not a nice user experience.

我觉得XMPP起得非常好,但我不太清楚如何灵活的解决方案,这可能是(如果我想保持一个单独的服务器上我的用户信息还等)。我也考虑使用原始TCP套接字(Node.js的服务器上是很容易操作)。

I think XMPP would fit nicely, but I'm not quite sure how flexible this solution can be ( what if I want to keep my users information on a separate server also etc. ). I also consider using a raw TCP socket ( Node.js on the server is fairly easy to operate ).

什么是目前最好的解决办法?

What's the best solution at the moment ?

推荐答案

那么,你的要求是pretty的多少:

Well, your requirements are pretty much:

实时 好友列表 presence 数据的共享

这些都是XMPP的所有功能,并有多种语言库实现可用。 啪 Java和的 xmppframework 为目标C将涉及您的特定用例。

These are all features of XMPP, and there are library implementation available in multiple languages. Smack for Java and xmppframework for Objective C will cover your particular use case.

您可以从接层起来写这个你自己,但是当有可用做什么,你需要现有的标准化协议和库何必呢。当你想添加的黑莓或其他平台的列表这样的话,我肯定 你可以很容易地找到合适的库,支持无需构建从地上爬起来的应用程序。

You could of course write this yourself from the socket layer up, but why bother when there are existing standardized protocols and libraries available to do what you need. This way when you want to add Blackberry or any other platform to your list, I am sure you can easily find the right library to support your app without having to build from the ground up.