最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - creating a mobile chat app with phonegap - best strategy? - Stack Overflow

programmeradmin2浏览0评论

Do I create a timer that does ajax requests every so often to check for new messages? This seems like it would be a huge drain on the phone.

What would be the best way to create a simple PhoneGap instant messaging/chat app?

Is HTTP streaming a tenable strategy for mobile devices? What if the connection is interrupted? Does it work on 3G?

Obviously this is a big question but any help would be much appreciated.

Do I create a timer that does ajax requests every so often to check for new messages? This seems like it would be a huge drain on the phone.

What would be the best way to create a simple PhoneGap instant messaging/chat app?

Is HTTP streaming a tenable strategy for mobile devices? What if the connection is interrupted? Does it work on 3G?

Obviously this is a big question but any help would be much appreciated.

Share Improve this question edited May 5, 2012 at 16:19 Jeff LaFay 13.4k14 gold badges73 silver badges102 bronze badges asked Dec 22, 2011 at 20:48 JustinJustin 3,6343 gold badges29 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

This question is a little high level in scope and a lot would go into a "total answer". It depends on what you're using but have you considered using node.js and websockets? I know there are other ways to do server side websockets but that is a popular one.

If you're not familiar with web sockets, it's a new HTML5 technology and the mobile platforms seem to be keeping right along with HTML5 technologies so this may be a viable solution for you if you're still looking for something.

The thing with web sockets is that you don't poll for new data as what you have speculated in your question. It maintains an open connection between the server and the client. That way, the server only needs to push new data to the client when it arrives and vice versa when you want to push data to the server. You use a lot less data and processing since you don't periodically check for data. Also it's more of a "realtime" experience since messages are propagated after the server receives them.

Doing a general google search for websockets and chat yield all kinds of tutorials available.

Hope that helps.

发布评论

评论列表(0)

  1. 暂无评论