pub fn update(&mut self, socket: &mut dyn Socket) -> Result<()> {
        if NetworkState::Disconnected == self.state() {
            return Ok(());
        }
        if self.send.last_ping.elapsed().as_secs_f64() > TParam::PING_INTERVAL_S {
            self.send_ping(socket)?;
        }
        for missing_packet in &mut self.receive.missing_message_id_list {
            if missing_packet.last_request.elapsed().as_secs_f64()
                > TParam::REQUEST_MISSING_PACKET_INTERVAL_S
            {
                send_packet_to::<TParam::TSend>(
                    self.peer_addr,
                    socket,
                    &Packet::RequestPacket {
                        id: missing_packet.id,
                    },
                )?;
                missing_packet.last_request = Instant::now();
            }
        }
        for unconfirmed_packet in self.send.unconfirmed_message_cache.values_mut() {
            if unconfirmed_packet.last_emit.elapsed().as_secs_f64()
                > TParam::EMIT_UNCONFIRMED_PACKET_INTERVAL_S
            {
                unconfirmed_packet.last_emit = Instant::now();
                send_packet_to(self.peer_addr, socket, &unconfirmed_packet.packet)?;
            }
        }
        Ok(())
    }
/// Update this connector. This will make sure the connection is still intact and requests any potentially missing packets.
Update this connector. This will make sure the connection is still intact and requests any potentially missing packets.
Update this connector . This will make sure the connection is still intact and requests any potentially missing packets .
pub fn update(&mut self, socket: &mut dyn Socket) -> Result<()> {
        if NetworkState::Disconnected == self.state() {
            return Ok(());
        }
        if self.send.last_ping.elapsed().as_secs_f64() > TParam::PING_INTERVAL_S {
            self.send_ping(socket)?;
        }
        for missing_packet in &mut self.receive.missing_message_id_list {
            if missing_packet.last_request.elapsed().as_secs_f64()
                > TParam::REQUEST_MISSING_PACKET_INTERVAL_S
            {
                send_packet_to::<TParam::TSend>(
                    self.peer_addr,
                    socket,
                    &Packet::RequestPacket {
                        id: missing_packet.id,
                    },
                )?;
                missing_packet.last_request = Instant::now();
            }
        }
        for unconfirmed_packet in self.send.unconfirmed_message_cache.values_mut() {
            if unconfirmed_packet.last_emit.elapsed().as_secs_f64()
                > TParam::EMIT_UNCONFIRMED_PACKET_INTERVAL_S
            {
                unconfirmed_packet.last_emit = Instant::now();
                send_packet_to(self.peer_addr, socket, &unconfirmed_packet.packet)?;
            }
        }
        Ok(())
    }
pub fn update ( & mut self , socket : & mut dyn Socket ) -> Result < ( ) > { if NetworkState :: Disconnected == self . state ( ) { return Ok ( ( ) ) ; } if self . send . last_ping . elapsed ( ) . as_secs_f64 ( ) > TParam :: PING_INTERVAL_S { self . send_ping ( socket ) ? ; } for missing_packet in & mut self . receive . missing_message_id_list { if missing_packet . last_request . elapsed ( ) . as_secs_f64 ( ) > TParam :: REQUEST_MISSING_PACKET_INTERVAL_S { send_packet_to :: < TParam :: TSend > ( self . peer_addr , socket , & Packet :: RequestPacket { id : missing_packet . id , } , ) ? ; missing_packet . last_request = Instant :: now ( ) ; } } for unconfirmed_packet in self . send . unconfirmed_message_cache . values_mut ( ) { if unconfirmed_packet . last_emit . elapsed ( ) . as_secs_f64 ( ) > TParam :: EMIT_UNCONFIRMED_PACKET_INTERVAL_S { unconfirmed_packet . last_emit = Instant :: now ( ) ; send_packet_to ( self . peer_addr , socket , & unconfirmed_packet . packet ) ? ; } } Ok ( ( ) ) }
Update this connector.
Update this connector .
&mut self
socket
&mut dyn Socket
&mut self
socket
&mut dyn Socket