MSServerSentEvents 0.1.0

MSServerSentEvents 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jul 2015

Maintained by Simon Heys.



An Objective-C implementation of Server-Sent Events

Usage

Simply initialise an event source and then subscribe to receive events:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:@"http://127.0.0.1:8888/"];

MSServerSentEventsSource *serverSentEventsSource = [[MSServerSentEventsSource alloc] initWithRequest:request receive:^(MSServerSentEvent *event) {
    NSLog(@"received:%@",event);
}
completion:^{
    NSLog(@"closed");
}
failure:^(NSError *error) {
    NSLog(@"error:%@",error);
}];

[serverSentEventsSource addListenerForEvent:@"open" usingBlock:^(MSServerSentEvent *event) {
    NSLog(@"received open event");
}];

[serverSentEventsSource addListenerForEvent:@"message" usingBlock:^(MSServerSentEvent *event) {
    NSLog(@"received message event");
}];

Installation

MSServerSentEvents is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MSServerSentEvents"

Author

Simon Heys, [email protected]

License

MSServerSentEvents is available under the MIT license. See the LICENSE file for more info.