fn connect(&mut self) -> Result<()> {
        self.conn_state = ConnectionState::Connecting;

        let host_port = vec![
            self.config.server.clone(),
            ":".to_string(),
            self.config.port.to_string(),
        ]
        .join("");
        let addrs = host_port.to_socket_addrs()?.collect::<Vec<_>>();
        let addr = addrs.first().ok_or(BlynkError::Dns)?;

        let stream = TcpStream::connect_timeout(addr, conf::SOCK_TIMEOUT)?;
        self.client.set_stream(stream);

        info!("Successfully connected to blynk server");

        self.authenticate(&self.config.token.clone())?;
        self.set_heartbeat()?;

        self.last_rcv_time = Instant::now();

        if let Some(hook) = &mut self.handler {
            hook.handle_connect(&mut self.client);
        }
        Ok(())
    }
/// Connects to Blynk servers
///
/// Performs authentication and sets up heart beat with the servers
///
/// Calls hook in event of succseful handshake
Connects to Blynk servers
Performs authentication and sets up heart beat with the servers

Calls hook in event of succseful handshake
Connects to Blynk servers Performs authentication and sets up heart beat with the servers Calls hook in event of succseful handshake
fn connect(&mut self) -> Result<()> {
        self.conn_state = ConnectionState::Connecting;
        let host_port = vec![
            self.config.server.clone(),
            ":".to_string(),
            self.config.port.to_string(),
        ]
        .join("");
        let addrs = host_port.to_socket_addrs()?.collect::<Vec<_>>();
        let addr = addrs.first().ok_or(BlynkError::Dns)?;
        let stream = TcpStream::connect_timeout(addr, conf::SOCK_TIMEOUT)?;
        self.client.set_stream(stream);
        info!("Successfully connected to blynk server");
        self.authenticate(&self.config.token.clone())?;
        self.set_heartbeat()?;
        self.last_rcv_time = Instant::now();
        if let Some(hook) = &mut self.handler {
            hook.handle_connect(&mut self.client);
        }
        Ok(())
    }
fn connect ( & mut self ) -> Result < ( ) > { self . conn_state = ConnectionState :: Connecting ; let host_port = vec ! [ self config server clone ( ) " " to_string ( ) self config port to_string ( ) ] . join ( " " ) ; let addrs = host_port . to_socket_addrs ( ) ? . collect :: < Vec < _ > > ( ) ; let addr = addrs . first ( ) . ok_or ( BlynkError :: Dns ) ? ; let stream = TcpStream :: connect_timeout ( addr , conf :: SOCK_TIMEOUT ) ? ; self . client . set_stream ( stream ) ; info ! ( " " ) ; self . authenticate ( & self . config . token . clone ( ) ) ? ; self . set_heartbeat ( ) ? ; self . last_rcv_time = Instant :: now ( ) ; if let Some ( hook ) = & mut self . handler { hook . handle_connect ( & mut self . client ) ; } Ok ( ( ) ) }
Connects to Blynk servers
Performs authentication and sets up heart beat with the servers
Connects to Blynk servers Performs authentication and sets up heart beat with the servers
&mut self
&mut self