/// heartbeat method, sends ping to client at HEARTBEAT_INTERVAL
/// checks heartbeats from client
heartbeat method, sends ping to client at HEARTBEAT_INTERVAL
checks heartbeats from client
heartbeat method sends ping to client at HEARTBEAT_INTERVAL checks heartbeats from client
fn hb(&self, ctx: &mut <Self as Actor>::Context) {
        ctx.run_interval(HEARTBEAT_INTERVAL, |act, ctx| {
            // check client heartbeats
            if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
                // heartbeat timed out
                if log_enabled!(Level::Error) {
                    error!("websocket heartbeat failed, disconnecting!");
                }                
                // stop actor
                ctx.stop();
                // don't try to send a ping
                return;
            }
            // send ping
            ctx.ping(b"");
        });
    }
fn hb ( & self , ctx : & mut < Self as Actor > :: Context ) { ctx . run_interval ( HEARTBEAT_INTERVAL , | act , ctx | { // check client heartbeats if Instant :: now ( ) . duration_since ( act . hb ) > CLIENT_TIMEOUT { // heartbeat timed out if log_enabled ! ( Level Error ) { error ! ( " " ) ; } // stop actor ctx . stop ( ) ; // don't try to send a ping return ; } // send ping ctx . ping ( b" " ) ; } ) ; }
heartbeat method, sends ping to client at HEARTBEAT_INTERVAL
checks heartbeats from client
heartbeat method sends ping to client at HEARTBEAT_INTERVAL checks heartbeats from client
&self
ctx
&mut <Self as Actor>::Context