EventSource implementation in Rust to handle streams of Server-Sent Events
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
Cargo.toml
LICENSE
README.md

README.md

SSE Client

Documentation

EventSource implementation in Rust to handle streams of Server-Sent Events. It handles connections, redirections, retries and message parsing.

To know more about SSE: Standard | EventSource interface

Example:

Usage:

extern crate sse_client;
use sse_client::EventSource;


let event_source = EventSource::new("http://event-stream-address/sub").unwrap();

event_source.on_message(|message| {
    println!("New message event {:?}", message);
});

event_source.add_event_listener("error", |error| {
    println!("Error {:?}", error);
});

Or:

extern crate sse_client;
use sse_client::EventSource;

let event_source = EventSource::new("http://event-stream-address/sub").unwrap();

for event in event_source.receiver().iter() {
    println!("New Message: {}", event.data);
}