views:

78

answers:

2

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).

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...

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.

A: 

In my opinion the best solution is socket, but you say that you can't implement the server side for this.

You could also implement it with push notifications. You can receive the push also when your app is running and send all the data you need inside the push. Usually chat messages are short...

If you don't want to mess with push notifications on the server then the only thing left, as long as I know, is the polling.

Michael Kessler
A: 

I think you can either go with push notifications, or XMPP (Jabber) server.

XMPP will allow your iphone app to receive data even when in the background using the new multitasking features (listening for a socket), and i'm pretty sure you should find ready to use servers for LAMP (or at least open source implementations).

Note that the iOS4 multitasking API doesn't support polling in the background, so your only other option should be push notifications. If you're new to push notifications, you can maybe use a service like Urban Airship that might make the process easier.

Ron Srebro