pub fn spawn_heartbeat_loop(
    period: Duration,
    client_id: u64,
    outgoing_sender: mpsc::UnboundedSender<(AbsintheWSRequest, Option<oneshot::Receiver<bool>>)>,
) {
    tokio::spawn(async move {
        loop {
            let heartbeat = AbsintheWSRequest::new(
                client_id,
                HEARTBEAT_MESSAGE_ID, // 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, None)) {
                // if outgoing sender is dead just ignore, will be handled elsewhere
                break;
            }
            tokio::time::sleep(period).await;
        }
    });
}
// this will add heartbeat (keep alive) messages to the channel for ws to send out every 15s
this will add heartbeat (keep alive) messages to the channel for ws to send out every 15s
this will add heartbeat ( keep alive ) messages to the channel for ws to send out every 15s
pub fn spawn_heartbeat_loop(
    period: Duration,
    client_id: u64,
    outgoing_sender: mpsc::UnboundedSender<(AbsintheWSRequest, Option<oneshot::Receiver<bool>>)>,
) {
    tokio::spawn(async move {
        loop {
            let heartbeat = AbsintheWSRequest::new(
                client_id,
                HEARTBEAT_MESSAGE_ID, // 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, None)) {
                // if outgoing sender is dead just ignore, will be handled elsewhere
                break;
            }
            tokio::time::sleep(period).await;
        }
    });
}
pub fn spawn_heartbeat_loop ( period : Duration , client_id : u64 , outgoing_sender : mpsc :: UnboundedSender < ( AbsintheWSRequest , Option < oneshot :: Receiver < bool > > ) > , ) { tokio :: spawn ( async move { loop { let heartbeat = AbsintheWSRequest :: new ( client_id , HEARTBEAT_MESSAGE_ID , // 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 , None ) ) { // if outgoing sender is dead just ignore, will be handled elsewhere break ; } tokio :: time :: sleep ( period ) . await ; } } ) ; }
this will add heartbeat (keep alive) messages to the channel for ws to send out every 15s
this will add heartbeat ( keep alive ) messages to the channel for ws to send out every 15s
period
Duration
client_id
u64
outgoing_sender
mpsc::UnboundedSender<(AbsintheWSRequest, Option<oneshot::Receiver<bool>>)>