Skip to content

viniciusgerevini/sse-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

EventSource implementation in Rust to handle streams of Server-Sent Events

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages