hyper-sse

crates.io version docs.rs version

Simple Server-Sent Events (SSE) library for hyper and Rocket using JSON for message encoding.

Example

toml [dependencies] hyper-sse = "0.1" lazy_static = "1"

```rust extern crate hyper_sse;

[macrouse] extern crate lazystatic;

use hyper_sse::Server; use std::io::BufRead;

lazy_static! { static ref SSE: Server = Server::new(); }

fn main() { SSE.spawn("[::1]:3000".parse().unwrap());

// Use SSE.generate_auth_token(_) to generate auth tokens

let stdin = std::io::stdin();
for line in stdin.lock().lines() {
    let line = line.unwrap();

    SSE.push(0, "update", &line).ok();
}

} ```

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.