I have an iPhone application that needs to be updated as soon as a change is made to the server. How can I have the server "push" data to the iphone rather than the iphone constantly polling the web service?
EDIT: I want th iPhone to receive JSON updates as soon as the server processes them, without having to request.
I suppose since the server is a web service that this is called Comet, but I haven't seen a good iPhone example yet.
That depends on how adventurous you are. There are two alternatives here:
UPDATE: Take a look at iStreamLight - Lightstreamer protocol implementation for iPhone. If it doesn't fit your Comet web-service, you probably need to go down to the lower level, which is maintaining TCP connection using socket streams. To simplify your task in handling JSON data structures, you might want to use JSON framework for Objective-C.
What you need is some sort of COMET framework (such as light-streamer). There are a several ways to do that - socket connections or HTTP server that hold onto your polls until there is some data available to deliver or until the HTTP request times out. Other options include using plug-ins such like Flash or Silverlight/Moonlight (assuming such a thing were possible on the iphone using monotouch?)
A good new (IIS based) COMET framework that can move a lot of data in a very performant way is WebSync from Frozen Mountain, that supports a hosted COMET based PubSub framework (called WebSync on Demand) that can scale to suit your load. It works nicely via Javascript, and has a pretty clean API.
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