6

Has anyone managed to get Server-Sent-Events (SSE) working nicely through AFNetworking? I know AFURLConnectionOperation has an inputStream property I can attach to, but the architecture of AFNetworking seems to be oriented around receiving a response, so I'm not sure what the best way to go about it would be.

Any on how to structure such a program would be appreciated. I'm also open to other iOS libraries, if they provide cleaner solutions.

elsurudo
  • 3,579
  • 2
  • 31
  • 48
  • I think what you want doesn't exist as an iOS framework, except maybe ASIHTTPRequest: http://stackoverflow.com/q/12940831/1445366 – Aaron Brager Jul 15 '13 at 19:18
  • Yeah, I saw that question as well. The problem with ASIHTTPRequest is that it doesn't look like it's being maintained these days. I managed to put together a decently-working half-solution on top of AFNetworking, however, using NSStreams. Once I get it fully working, I'll see if I can get it into AFNetworking proper. – elsurudo Jul 17 '13 at 11:17
  • Sounds interesting. I'm happy to test / code review if you want to throw it on Github. – Aaron Brager Jul 17 '13 at 14:59
  • 1
    I decided to go another way, and ended up not needing AFNetworking at all... no external dependencies. Still needs more testing and work, but worked well for my current needs. Check it out, input welcome: https://gist.github.com/elsurudo/6039065 – elsurudo Jul 19 '13 at 13:23

1 Answers1

2

AFRocketClient (built on top of AFNetworking 2.0) contains AFEventSource which is an implementation of the W3C Event Source API.

The combination of Server Side Events and JSON Patch is being referred to as Rocket.

Robert Atkins
  • 23,528
  • 15
  • 68
  • 97
  • suggested a really good solution above, I'm going to try it out now. – deadlock Jan 10 '14 at 17:19
  • Is there anyone really successfully use this at all? I have big issue with the library- no event is fired after connection and it complains event source is already open. – William Yeung Aug 18 '14 at 08:20