/// Disconnect from MQTT broker
///
/// Send disconnect message to broker. This leads into breaking the socket so new Client needs to be created
/// for new connections
///
Disconnect from MQTT broker
Send disconnect message to broker. This leads into breaking the socket so new Client needs to be created
for new connections
Disconnect from MQTT broker Send disconnect message to broker . This leads into breaking the socket so new Client needs to be created for new connections
pub async fn disconnect(&mut self) -> Result<&Self, MqttError> {
        // Allocate write buffer.
        info!("--Disconnect--");
        let mut raw_buf = [0 as u8; 8];
        let pkt = mqttrs::Packet::Disconnect;
        let length = mqttrs::encode_slice(&pkt, &mut raw_buf)?;
        let buf = BytesMut::from(&raw_buf[..length]);
        let msg = ChannelPacket::Generic(MqttMsg::new(-1, buf));
        self.tx_stream
            .send(msg)
            .await
            .map_err(|_| MqttError::AsyncChannelSendError)?;
        info!("Disconnect complete");
        Ok(self)
    }
pub async fn disconnect ( & mut self ) -> Result < & Self , MqttError > { // Allocate write buffer. info ! ( " " ) ; let mut raw_buf = [ 0 as u8 ; 8 ] ; let pkt = mqttrs :: Packet :: Disconnect ; let length = mqttrs :: encode_slice ( & pkt , & mut raw_buf ) ? ; let buf = BytesMut :: from ( & raw_buf [ .. length ] ) ; let msg = ChannelPacket :: Generic ( MqttMsg :: new ( - 1 , buf ) ) ; self . tx_stream . send ( msg ) . await . map_err ( | _ | MqttError :: AsyncChannelSendError ) ? ; info ! ( " " ) ; Ok ( self ) }
Disconnect from MQTT broker
Send disconnect message to broker.
Disconnect from MQTT broker Send disconnect message to broker .
&mut self