开发者

Implementing realtime apps on the iPhone?

Things like presence notification needed for IM that messenger apps have. Kik does this especially well and managed to improve the texting experience many-fold.

If this were a web application, we would probably do a comet imple开发者_运维百科mentation and run an event loop server to handle the connections and keep either a flash/web socket or long polling connection open on the client (Socket.IO ftw).

I'm not too sure about iPhone, with the connections over 3g+wifi and all: - maybe NSURLRequest handles all that stuff for you and it's as simple as keeping a long running long polling connection on a background thread and register notifications onto it?

Anyways, would appreciate some pointers from anybody who's implemented something realtime on the iPhone.


Well I'll just respond now for other peoples' reference:

You can use Node.js with Socket.io basically, and implement long polling on the iPhone. There's a library somewhere IIRC, but it's relatively simple just to implement yourself:

  • Implement a state machine of sorts on the phone to switch between open request and getting back data, fire off another request.
  • Implement a heartbeat (you don't want to hit the HTTP timeout anyways) of like 5 seconds, read the socket.io github page for more info on the protocol so you can interface with Node.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜