Skip to content

ATommyGirl/YYEventSource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

YYEventSource

博客:Server-Sent Events / EventSource

Start server on http://127.0.0.1:8844/stream.
node sse-server.js
Open the url in browser.
or
Request by OC code.
#import "EventSource.h"

connect:

NSString *url = @"http://127.0.0.1:8844/stream";
EventSource *eventSource = [EventSource eventSourceWithURL:[NSURL URLWithString:url]];

[eventSource onMessage:^(Event *e) {
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"%@", e);
    });
}];

[eventSource onError:^(Event *event) {
    NSLog(@"error:%@", event.error);
}];

You will see the message in console.

PS: Base on code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published