pub fn create_stream(clients: &mut Clients, src: IpAddr) -> Response<Body> {
    let (sender, body) = Body::channel();

    let drained = clients.drain_filter(|client| client.dest == src);
    for client in drained {
        client.tx.abort();
    }
    clients.push_back(Client { tx: sender, dest: src });

    info!("SSE Client added: {:?}. Clients: {}", src, clients.len());

    Response::builder()
        .header("connection", "keep-alive")
        .header("cache-control", "no-cache")
        .header("x-accel-buffering", "no")
        .header("content-type", "text/event-stream")
        .header("access-control-allow-origin", "*")
        .body(body)
        .expect("Could not create response")
}
/// Initiate a new SSE stream for the given request and request IP.
/// Each IP can only have one stream. If there is already an existing one,
/// the old one will be closed and overwritten.
Initiate a new SSE stream for the given request and request IP.
Each IP can only have one stream. If there is already an existing one,
the old one will be closed and overwritten.
Initiate a new SSE stream for the given request and request IP . Each IP can only have one stream . If there is already an existing one the old one will be closed and overwritten .
pub fn create_stream(clients: &mut Clients, src: IpAddr) -> Response<Body> {
    let (sender, body) = Body::channel();
    let drained = clients.drain_filter(|client| client.dest == src);
    for client in drained {
        client.tx.abort();
    }
    clients.push_back(Client { tx: sender, dest: src });
    info!("SSE Client added: {:?}. Clients: {}", src, clients.len());
    Response::builder()
        .header("connection", "keep-alive")
        .header("cache-control", "no-cache")
        .header("x-accel-buffering", "no")
        .header("content-type", "text/event-stream")
        .header("access-control-allow-origin", "*")
        .body(body)
        .expect("Could not create response")
}
pub fn create_stream ( clients : & mut Clients , src : IpAddr ) -> Response < Body > { let ( sender , body ) = Body :: channel ( ) ; let drained = clients . drain_filter ( | client | client . dest == src ) ; for client in drained { client . tx . abort ( ) ; } clients . push_back ( Client { tx : sender , dest : src } ) ; info ! ( " " src clients len ( ) ) ; Response :: builder ( ) . header ( " " , " " ) . header ( " " , " " ) . header ( " " , " " ) . header ( " " , " " ) . header ( " " , " " ) . body ( body ) . expect ( " " ) }
Initiate a new SSE stream for the given request and request IP.
Initiate a new SSE stream for the given request and request IP .
clients
&mut Clients
src
IpAddr
clients
&mut Clients
src
IpAddr