pub fn spawn_heartbeat_loop(client_id: u64, outgoing_sender: UnboundedSender<AbsintheWSRequest>) {
    tokio::spawn(async move {
        loop {
            let heartbeat = AbsintheWSRequest::new(
                client_id,
                0, // todo: this needs to increment but not overlap with other message ids
                AbsintheTopic::Phoenix,
                AbsintheEvent::Heartbeat,
                None,
            );
            if let Err(_ignore) = outgoing_sender.send(heartbeat) {
                // if outgoing sender is dead just ignore, will be handled elsewhere
                break;
            }
            // every 15s
            delay_for(Duration::from_millis(15000)).await;
        }
    });
}
// this will add hearbeat (keep alive) messages to the channel for ws to send out every 15s
this will add hearbeat (keep alive) messages to the channel for ws to send out every 15s
this will add hearbeat ( keep alive ) messages to the channel for ws to send out every 15s
pub fn spawn_heartbeat_loop(client_id: u64, outgoing_sender: UnboundedSender<AbsintheWSRequest>) {
    tokio::spawn(async move {
        loop {
            let heartbeat = AbsintheWSRequest::new(
                client_id,
                0, // todo: this needs to increment but not overlap with other message ids
                AbsintheTopic::Phoenix,
                AbsintheEvent::Heartbeat,
                None,
            );
            if let Err(_ignore) = outgoing_sender.send(heartbeat) {
                // if outgoing sender is dead just ignore, will be handled elsewhere
                break;
            }
            // every 15s
            delay_for(Duration::from_millis(15000)).await;
        }
    });
}
pub fn spawn_heartbeat_loop ( client_id : u64 , outgoing_sender : UnboundedSender < AbsintheWSRequest > ) { tokio :: spawn ( async move { loop { let heartbeat = AbsintheWSRequest :: new ( client_id , 0 , // todo: this needs to increment but not overlap with other message ids AbsintheTopic :: Phoenix , AbsintheEvent :: Heartbeat , None , ) ; if let Err ( _ignore ) = outgoing_sender . send ( heartbeat ) { // if outgoing sender is dead just ignore, will be handled elsewhere break ; } // every 15s delay_for ( Duration :: from_millis ( 15000 ) ) . await ; } } ) ; }
this will add hearbeat (keep alive) messages to the channel for ws to send out every 15s
this will add hearbeat ( keep alive ) messages to the channel for ws to send out every 15s
client_id
u64
outgoing_sender
UnboundedSender<AbsintheWSRequest>
client_id
u64
outgoing_sender
UnboundedSender<AbsintheWSRequest>