fix #541 allow loop() to be called before begin()

This commit is contained in:
Links
2020-07-11 17:58:36 +02:00
parent a71a480676
commit 3f1cedb21c
2 changed files with 7 additions and 2 deletions

View File

@ -31,6 +31,8 @@ WebSocketsClient::WebSocketsClient() {
_client.cIsClient = true;
_client.extraHeaders = WEBSOCKETS_STRING("Origin: file://");
_reconnectInterval = 500;
_port = 0;
_host = "";
}
WebSocketsClient::~WebSocketsClient() {
@ -148,6 +150,9 @@ void WebSocketsClient::beginSocketIOSSLWithCA(const char * host, uint16_t port,
* called in arduino loop
*/
void WebSocketsClient::loop(void) {
if(_port == 0) {
return;
}
WEBSOCKETS_YIELD();
if(!clientIsConnected(&_client)) {
// do not flood the server