问题描述
我正在研究为iPhone制作基于聊天的应用程序(它不是常规意义上的文本聊天,但原则是相同的)。
I'm doing research for making a chat based app for the iPhone (it's not really text chat in the regular sense, but the principles are the same).
任何时候最多可以有6个人登录同一个聊天室,最基本的问题是如何有效地检查新消息?
Maximum 6 people can be logged into the same chat room at any one time, and the most basic question is how to efficiently check for new messages?
我是否需要定期轮询服务器?或者,有什么方法可以在服务器上通过电话触发事件,只要有一些新内容需要注意?
Would I need to simply poll the server periodically? Or is there a way I could trigger an event on the phone from the server whenever there is some new content to pay attention to?
如果必须一直轮询,我担心由此造成的滞后,因为每个参与者在向其他人发布自己的回复之前必须等待更长时间。并且,处理服务器以便始终响应大量请求可能也是太过分了。它也会浪费带宽,这对用户来说是免费的......
If having to poll all the time, I worry about the resulting lag as each participant will have to wait longer for others before they can post their own responses to others. And, potentially it might also be too much to handle for the server to respond to lots of requests all the time. It would also waste bandwidth, which is not free for the user...
不幸的是我无法为这个应用程序设置套接字服务器,它必须基于常规LAMP配置。
Unfortunately I will not be able to set up a socket server for this app, it has to be based around a regular LAMP configuration.
推荐答案
XMPP听起来不错,我认为这是聊天的最佳技术。它在iOS应用程序中运行良好。
XMPP sounds good for you idea, i think this is the best technology for Chat. It alos works great in iOS apps.
也许这个代码示例将有助于在iOS应用程序中开始使用XMPP - 看看这个。它演示了如何将1-1聊天,聊天室内整合到您的Android应用程序中。还有指南如何工作。我认为将它集成到您的应用程序中是没有问题的。否则 - 评论以下系统可以提出您想要的任何问题并快速回答。
Maybe this code sample will be helpful to start using XMPP in iOS app - look at this QuickBlox Chat code sample. It demonstrates how to integrate 1-1 Chat, Chat in room into your android application. Also there is guide how it works. I think there will be no problem to integrate it into your application. Otherwise - Comments system below allows to ask any question you want and get fast answer.
此外还有演示视频这是怎么回事聊天工作。
Also there is Demo video http://www.youtube.com/watch?feature=player_embedded&v=SncQaJBBW_0 how this Chat works.
这篇关于如何在iPhone上建立聊天系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!