This pull request introduces functionality for handling MQTT PINGREQ and PINGRESP packets, along with some code cleanup and refactoring. The most important changes include the addition of a new function to read PINGRESP packets, modifications to the main event loop to handle keep-alive messages, and updates to the packet module to support PINGREQ packets.
MQTT Keep-Alive Functionality:
src/client.rs: Added read_pingresp function to read PINGRESP packets from the stream.
src/main.rs: Modified the main event loop to send PINGREQ packets periodically and handle PINGRESP packets.
Packet Type Enhancements:
src/packet.rs: Added PingReq to the PacketType enum.
src/packet.rs: Implemented the MqttPingReq struct with an encode method to create PINGREQ packets.
Code Cleanup:
src/packet.rs: Corrected the packet type used in the MqttPublish struct's encode method.
This pull request introduces functionality for handling MQTT
PINGREQ
andPINGRESP
packets, along with some code cleanup and refactoring. The most important changes include the addition of a new function to readPINGRESP
packets, modifications to the main event loop to handle keep-alive messages, and updates to thepacket
module to supportPINGREQ
packets.MQTT Keep-Alive Functionality:
src/client.rs
: Addedread_pingresp
function to readPINGRESP
packets from the stream.src/main.rs
: Modified the main event loop to sendPINGREQ
packets periodically and handlePINGRESP
packets.Packet Type Enhancements:
src/packet.rs
: AddedPingReq
to thePacketType
enum.src/packet.rs
: Implemented theMqttPingReq
struct with anencode
method to createPINGREQ
packets.Code Cleanup:
src/packet.rs
: Corrected the packet type used in theMqttPublish
struct'sencode
method.