async fn broadcast_page(sender_id: i64, comic: &str, page: &str) {
    let clients = &mut STATUS.lock().await.connections;
    let msg = warp::ws::Message::text(json!({"comic": comic, "page": page}).to_string());
    let mut disconnected_clients = vec![];
    for client in clients.iter_mut() {
        if client.id == sender_id {
            continue;
        }
        log::debug!(
            target: "scr::sharing_service",
            "Sending message: {:?} to user {}",
            msg,
            client.id
        );
        match client.socket.send(msg.clone()).await {
            Err(_) => disconnected_clients.push(client.id),
            _ => {}
        }
    }

    if !disconnected_clients.is_empty() {
        log::debug!(
            target: "scr::sharing_service",
            "Disconnected clients: {:?}",
            disconnected_clients
        );

        clients.retain(|client| !disconnected_clients.contains(&client.id));
    }
}
// When one client turns the page, broadcasts a message to every other client making
// them turn the page too.
When one client turns the page, broadcasts a message to every other client making
them turn the page too.
When one client turns the page broadcasts a message to every other client making them turn the page too .
async fn broadcast_page(sender_id: i64, comic: &str, page: &str) {
    let clients = &mut STATUS.lock().await.connections;
    let msg = warp::ws::Message::text(json!({"comic": comic, "page": page}).to_string());
    let mut disconnected_clients = vec![];
    for client in clients.iter_mut() {
        if client.id == sender_id {
            continue;
        }
        log::debug!(
            target: "scr::sharing_service",
            "Sending message: {:?} to user {}",
            msg,
            client.id
        );
        match client.socket.send(msg.clone()).await {
            Err(_) => disconnected_clients.push(client.id),
            _ => {}
        }
    }
    if !disconnected_clients.is_empty() {
        log::debug!(
            target: "scr::sharing_service",
            "Disconnected clients: {:?}",
            disconnected_clients
        );
        clients.retain(|client| !disconnected_clients.contains(&client.id));
    }
}
async fn broadcast_page ( sender_id : i64 , comic : & str , page : & str ) { let clients = & mut STATUS . lock ( ) . await . connections ; let msg = warp :: ws :: Message :: text ( json ! ( { " " comic " " page } ) . to_string ( ) ) ; let mut disconnected_clients = vec ! [ ] ; for client in clients . iter_mut ( ) { if client . id == sender_id { continue ; } log :: debug ! ( target " " " " msg client id ) ; match client . socket . send ( msg . clone ( ) ) . await { Err ( _ ) => disconnected_clients . push ( client . id ) , _ => { } } } if ! disconnected_clients . is_empty ( ) { log :: debug ! ( target " " " " disconnected_clients ) ; clients . retain ( | client | ! disconnected_clients . contains ( & client . id ) ) ; } }
When one client turns the page, broadcasts a message to every other client making
them turn the page too.
When one client turns the page broadcasts a message to every other client making them turn the page too .
sender_id
i64
comic
&str
page
&str
sender_id
i64
comic
&str
page
&str