fn hb(&mut self, ctx: &mut <Self as Actor>::Context) {
        ctx.run_interval(HEARTBEAT_INTERVAL, move |act, ctx| {
            if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
                log::warn!("Websocket client heartbeat failed, disconnecting!");
                ctx.stop();
                return;
            }
            if act.sink.write(ws::Message::Ping("".into())).is_some() {
                log::warn!("Websocket client failed to send ping, stopping!");
                ctx.stop()
            };
        });
    }
/// helper method that sends ping to client every second.
///
/// also this method checks heartbeats from client
helper method that sends ping to client every second.
also this method checks heartbeats from client
helper method that sends ping to client every second . also this method checks heartbeats from client
fn hb(&mut self, ctx: &mut <Self as Actor>::Context) {
        ctx.run_interval(HEARTBEAT_INTERVAL, move |act, ctx| {
            if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
                log::warn!("Websocket client heartbeat failed, disconnecting!");
                ctx.stop();
                return;
            }
            if act.sink.write(ws::Message::Ping("".into())).is_some() {
                log::warn!("Websocket client failed to send ping, stopping!");
                ctx.stop()
            };
        });
    }
fn hb ( & mut self , ctx : & mut < Self as Actor > :: Context ) { ctx . run_interval ( HEARTBEAT_INTERVAL , move | act , ctx | { if Instant :: now ( ) . duration_since ( act . hb ) > CLIENT_TIMEOUT { log :: warn ! ( " " ) ; ctx . stop ( ) ; return ; } if act . sink . write ( ws :: Message :: Ping ( " " . into ( ) ) ) . is_some ( ) { log :: warn ! ( " " ) ; ctx . stop ( ) } ; } ) ; }
helper method that sends ping to client every second.
helper method that sends ping to client every second .
&mut self
ctx
&mut <Self as Actor>::Context
&mut self
ctx
&mut <Self as Actor>::Context