hirotakaster / MQTT

MQTT for Photon, Spark Core
Other
216 stars 118 forks source link

Proposal for addition of custom keep-alive interval #48

Closed imaustink closed 7 years ago

imaustink commented 7 years ago

I am interested in adding a custom keep alive interval to this library. A recent project requires a near real-time notification of disconnected client. A keep-alive interval of 1 second should be fine.

I imagine something like:

#include "MQTT.h"

// Optional third arg of the constructor is an Int representing number of seconds
MQTT client(server, 1883, 1, callback);

void setup() {
    client.connect("ClientName");
    if (client.isConnected()) client.publish("test","Hello World");
}

void loop() {
    if (client.isConnected()) client.loop();
}

PR ready for comment: #49

hirotakaster commented 7 years ago

hi @imaustink thank you for your pull request!! I will check your commit and merge later.

hirotakaster commented 7 years ago

okay, now I merge all your commit. Arduino compatible code parts are deleted but it maybe no problem:)

imaustink commented 7 years ago

Thank you kind sir for the timely response!

I know the Arduino stuff isn't an problem but I feel that for maintainability moving forward it would be good to have a better separation for platforms and a cleaner codebase for them as well :)

Thanks!

hirotakaster commented 7 years ago

Yes, already update to Particle library version 0.4.6. Please check it and close this issue.