1 unstable release

Uses old Rust 2015

0.1.0 Jul 8, 2018

#10 in #lazy-static

Apache-2.0/MIT

14KB
204 lines

hyper-sse

crates.io version docs.rs version

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

Example

[dependencies]
hyper-sse = "0.1"
lazy_static = "1"
extern crate hyper_sse;
#[macro_use] extern crate lazy_static;

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

lazy_static! {
    static ref SSE: Server<u8> = 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.

Dependencies

~10–13MB
~238K SLoC