Skip to content Skip to sidebar Skip to footer

Creating A Mobile Chat App With Phonegap - Best Strategy?

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

Solution 1:

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.


Post a Comment for "Creating A Mobile Chat App With Phonegap - Best Strategy?"