PubSubClient: Add disconnect type option

This commit is contained in:
Adrian Scillato 2019-12-15 16:40:02 -03:00 committed by GitHub
parent 765cecd4a3
commit 946f6fd74f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -610,11 +610,13 @@ boolean PubSubClient::unsubscribe(const char* topic) {
return false; return false;
} }
void PubSubClient::disconnect() { void PubSubClient::disconnect(bool disconnect_package) {
buffer[0] = MQTTDISCONNECT; buffer[0] = MQTTDISCONNECT;
buffer[1] = 0; buffer[1] = 0;
if (_client != nullptr) { if (_client != nullptr) {
_client->write(buffer,2); if (disconnect_package) {
_client->write(buffer,2);
}
_client->flush(); _client->flush();
_client->stop(); _client->stop();
} }