Crates.io | hyper-sse |
lib.rs | hyper-sse |
version | 0.1.0 |
source | src |
created_at | 2018-07-08 23:14:33.240108 |
updated_at | 2018-07-08 23:14:33.240108 |
description | Server-Sent Events (SSE) library for hyper and Rocket |
homepage | |
repository | https://github.com/klemens/hyper-sse |
max_upload_size | |
id | 73416 |
size | 16,905 |
Simple Server-Sent Events (SSE) library for hyper and Rocket using JSON for message encoding.
[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();
}
}
Licensed under either of
at your option.
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.