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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With