views:

301

answers:

1

I am writing a collection of web services, one of which needs to implement server push.

The client will be native Objective-C. I want this to be as simple, fast, and lightweight as possible. The data transmitted will be JSON. Is it possible to do this without using a message broker?

+1  A: 

There's an HTTP technique called COMET in which the client spins up a thread that makes a potentially very long-lived request to the HTTP server. Whenever the server wants to send something to the client, it sends a response to this request. The client processes this response and immediately makes another long-lived request to the server. In this way the server can send information while other things happen in the client's main execution thread(s). The information sent by the serve can be in any format you like. (In fact, for clients in a web browser doing COMET with a Javascript library, JSON is perfect.)

@DevDevDev: It's true that COMET is most often associated with a Javascript-enabled browser, but I don't think it has to be. You might check out iStreamLight, which is an Objective-C client for the iPhone that connects to COMET servers. It's also discussed in this interview with the author.

Jim Ferrans
Yes I know very well about Comet. Technically speaking Comet applies only to In-browser Javascript (sort of the reverse of AJAX). Anyway if you have an example implementation of Non-message brokered Comet? More like a bi-directional web-service.
DevDevDev