fn hb(&self, ctx: &mut ws::WebsocketContext<Self>) {
        ctx.run_interval(HEARTBEAT_INTERVAL, |act, ctx| {
            // check client heartbeats
            if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
                // heartbeat timed out
                log::warn!("Websocket Client heartbeat failed, disconnecting!");

                // stop actor
                ctx.stop();

                // don't try to send a ping
                return;
            }
            
            ctx.ping(b"");
        });
    }
/// 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(&self, ctx: &mut ws::WebsocketContext<Self>) {
        ctx.run_interval(HEARTBEAT_INTERVAL, |act, ctx| {
            // check client heartbeats
            if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
                // heartbeat timed out
                log::warn!("Websocket Client heartbeat failed, disconnecting!");
                // stop actor
                ctx.stop();
                // don't try to send a ping
                return;
            }
            ctx.ping(b"");
        });
    }
fn hb ( & self , ctx : & mut ws :: WebsocketContext < Self > ) { ctx . run_interval ( HEARTBEAT_INTERVAL , | act , ctx | { // check client heartbeats if Instant :: now ( ) . duration_since ( act . hb ) > CLIENT_TIMEOUT { // heartbeat timed out log :: warn ! ( " " ) ; // stop actor ctx . stop ( ) ; // don't try to send a ping return ; } ctx . ping ( b" " ) ; } ) ; }
helper method that sends ping to client every second.
helper method that sends ping to client every second .
&self
ctx
&mut ws::WebsocketContext<Self>
&self
ctx
&mut ws::WebsocketContext<Self>