Update PubSubClient.cpp

Make sure all data is flushed to the other end when doing a disconnect(): that way we know for sure that it is there when we disconnect the wifi or maybe even reboot.
This change was made after I noticed that I did not get any mqtt messages. I verified that it indeed solves the problem. Example code on request.
This commit is contained in:
Folkert van Heusden 2018-09-07 21:39:45 +02:00 committed by GitHub
parent 54be6e87db
commit 0e2d6c322b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -524,6 +524,7 @@ void PubSubClient::disconnect() {
buffer[1] = 0; buffer[1] = 0;
_client->write(buffer,2); _client->write(buffer,2);
_state = MQTT_DISCONNECTED; _state = MQTT_DISCONNECTED;
_client->flush();
_client->stop(); _client->stop();
lastInActivity = lastOutActivity = millis(); lastInActivity = lastOutActivity = millis();
} }