Server-sent events EventSource client using NSURLSession
Objective-C Ruby JavaScript
Latest commit 3d42a86 Jun 13, 2016 @travisjeffery Release 0.0.8
Permalink
Failed to load latest commit information.
TRVSEventSource.xcodeproj Implement NSCopying, NSCoding, able to remove event handlers Dec 20, 2013
TRVSEventSource use self.operationQueue Jun 10, 2016
TRVSEventSourceExample Move test server into test dir Dec 14, 2013
TRVSEventSourceTests
.clang-format Remove sync queue. Mar 10, 2014
.gitignore
History.md Release 0.0.8 Jun 13, 2016
LICENSE.md Add license Oct 15, 2013
Podfile ++TRVSMonitor Dec 14, 2013
Podfile.lock ++TRVSMonitor Dec 14, 2013
README.md Typo in readme Dec 18, 2013
TRVSEventSource.podspec Release 0.0.8 Jun 13, 2016

README.md

TRVSEventSource

Server-sent events EventSource implementation in ObjC for iOS and OS X using NSURLSession.

Usage

TRVSEventSource *eventSource = [[TRVSEventSource alloc] initWithURL:URL];
eventSource.delegate = self;

[eventSource addListenerForEvent:@"message" usingEventHandler:^(TRVSServerSentEvent *event, NSError *error) {
    NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:event.data options:0 error:NULL];
    Message *message = [Message messageWithJSON:JSON];
}];

[eventSource open];

Local test server

Run the following to have a local server streaming events named message:

node TRVSEventSourceTests/server.js

❯ curl 127.0.0.1:8000
event: message
data: {"id": 1, "body":"1381466575460", "author_id": 1, "conversation_id": 1}

event: message
data: {"id": 2, "body":"1381466577463", "author_id": 1, "conversation_id": 1}