7 releases (stable)

Uses old Rust 2015

1.1.1 Mar 26, 2020
1.1.0 Jan 20, 2020
1.0.1 Dec 13, 2019
1.0.0 Oct 4, 2018
0.1.0 Aug 25, 2018

#9 in #event-source

Download history 19/week @ 2024-06-21 16/week @ 2024-06-28 16/week @ 2024-07-05 10/week @ 2024-07-12 23/week @ 2024-07-19 75/week @ 2024-07-26 42/week @ 2024-08-02 43/week @ 2024-08-09 70/week @ 2024-08-16 66/week @ 2024-08-23 46/week @ 2024-08-30 99/week @ 2024-09-06 37/week @ 2024-09-13 52/week @ 2024-09-20 50/week @ 2024-09-27 21/week @ 2024-10-04

171 downloads per month
Used in 2 crates

MIT/Apache

60KB
1.5K SLoC

SSE Client

Documentation Build Status

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);
}

Cargo features

  • native-tls enables support for HTTPS URLs using native-tls
  • native-tls-vendored will additionally link OpenSSL statically

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1–10MB
~136K SLoC