async fn run_inner(self) -> Result<()> {
        let duration = Duration::from_millis(self.interval);

        let mut last = true;

        loop {
            tokio::time::delay_for(duration).await;

            // Check if a heartbeat acknowledgement was received.
            //
            // If so, then check if one was received last time.
            //
            // - if so, then mark that we didn't get one this time
            // - if not, then end the heartbeater because something is off
            // (connecting closed?)
            if self.heartbeats.last_acked().await {
                last = true;
            } else if last {
                last = false;
            } else {
                return Ok(());
            }

            let seq = self.seq.load(Ordering::Acquire);
            let heartbeat = Heartbeat::new(seq);
            let bytes =
                serde_json::to_vec(&heartbeat).map_err(|source| Error::PayloadSerialization {
                    source,
                })?;

            debug!("[Heartbeat] Sending heartbeat with seq: {}", seq);
            self.tx
                .unbounded_send(TungsteniteMessage::Binary(bytes))
                .map_err(|source| Error::SendingMessage {
                    source,
                })?;
            debug!("[Heartbeat] Sent heartbeat with seq: {}", seq);
            self.heartbeats.send().await;
        }
    }
// If there's an issue sending over the channel, then odds are it
// got disconnected due to the session ending. This task should have
// *also* become aborted. Log if that's the case, because that's a
// programmatic error.
If there's an issue sending over the channel, then odds are it
got disconnected due to the session ending. This task should have
also* become aborted. Log if that's the case, because that's a
programmatic error.
If there ' s an issue sending over the channel then odds are it got disconnected due to the session ending . This task should have also * become aborted . Log if that ' s the case because that ' s a programmatic error .
async fn run_inner(self) -> Result<()> {
        let duration = Duration::from_millis(self.interval);
        let mut last = true;
        loop {
            tokio::time::delay_for(duration).await;
            // Check if a heartbeat acknowledgement was received.
            //
            // If so, then check if one was received last time.
            //
            // - if so, then mark that we didn't get one this time
            // - if not, then end the heartbeater because something is off
            // (connecting closed?)
            if self.heartbeats.last_acked().await {
                last = true;
            } else if last {
                last = false;
            } else {
                return Ok(());
            }
            let seq = self.seq.load(Ordering::Acquire);
            let heartbeat = Heartbeat::new(seq);
            let bytes =
                serde_json::to_vec(&heartbeat).map_err(|source| Error::PayloadSerialization {
                    source,
                })?;
            debug!("[Heartbeat] Sending heartbeat with seq: {}", seq);
            self.tx
                .unbounded_send(TungsteniteMessage::Binary(bytes))
                .map_err(|source| Error::SendingMessage {
                    source,
                })?;
            debug!("[Heartbeat] Sent heartbeat with seq: {}", seq);
            self.heartbeats.send().await;
        }
    }
async fn run_inner ( self ) -> Result < ( ) > { let duration = Duration :: from_millis ( self . interval ) ; let mut last = true ; loop { tokio :: time :: delay_for ( duration ) . await ; // Check if a heartbeat acknowledgement was received. // // If so, then check if one was received last time. // // - if so, then mark that we didn't get one this time // - if not, then end the heartbeater because something is off // (connecting closed?) if self . heartbeats . last_acked ( ) . await { last = true ; } else if last { last = false ; } else { return Ok ( ( ) ) ; } let seq = self . seq . load ( Ordering :: Acquire ) ; let heartbeat = Heartbeat :: new ( seq ) ; let bytes = serde_json :: to_vec ( & heartbeat ) . map_err ( | source | Error :: PayloadSerialization { source , } ) ? ; debug ! ( " " seq ) ; self . tx . unbounded_send ( TungsteniteMessage :: Binary ( bytes ) ) . map_err ( | source | Error :: SendingMessage { source , } ) ? ; debug ! ( " " seq ) ; self . heartbeats . send ( ) . await ; } }
If there's an issue sending over the channel, then odds are it
got disconnected due to the session ending.
If there ' s an issue sending over the channel then odds are it got disconnected due to the session ending .
self
self