Support pre-connected Client
This commit is contained in:
parent
26ce89fa47
commit
a4f7821a70
@ -121,11 +121,17 @@ boolean PubSubClient::connect(const char *id, const char *user, const char *pass
|
||||
if (!connected()) {
|
||||
int result = 0;
|
||||
|
||||
|
||||
if(_client->connected()) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (domain != NULL) {
|
||||
result = _client->connect(this->domain, this->port);
|
||||
} else {
|
||||
result = _client->connect(this->ip, this->port);
|
||||
}
|
||||
}
|
||||
|
||||
if (result == 1) {
|
||||
nextMsgId = 1;
|
||||
// Leave room in the buffer for header and variable length field
|
||||
@ -610,6 +616,8 @@ boolean PubSubClient::connected() {
|
||||
_client->flush();
|
||||
_client->stop();
|
||||
}
|
||||
} else {
|
||||
return this->_state == MQTT_CONNECTED;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user