mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-16 16:52:05 +02:00
fix #541 allow loop() to be called before begin()
This commit is contained in:
@ -31,6 +31,8 @@ WebSocketsClient::WebSocketsClient() {
|
|||||||
_client.cIsClient = true;
|
_client.cIsClient = true;
|
||||||
_client.extraHeaders = WEBSOCKETS_STRING("Origin: file://");
|
_client.extraHeaders = WEBSOCKETS_STRING("Origin: file://");
|
||||||
_reconnectInterval = 500;
|
_reconnectInterval = 500;
|
||||||
|
_port = 0;
|
||||||
|
_host = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketsClient::~WebSocketsClient() {
|
WebSocketsClient::~WebSocketsClient() {
|
||||||
@ -148,6 +150,9 @@ void WebSocketsClient::beginSocketIOSSLWithCA(const char * host, uint16_t port,
|
|||||||
* called in arduino loop
|
* called in arduino loop
|
||||||
*/
|
*/
|
||||||
void WebSocketsClient::loop(void) {
|
void WebSocketsClient::loop(void) {
|
||||||
|
if(_port == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
WEBSOCKETS_YIELD();
|
WEBSOCKETS_YIELD();
|
||||||
if(!clientIsConnected(&_client)) {
|
if(!clientIsConnected(&_client)) {
|
||||||
// do not flood the server
|
// do not flood the server
|
||||||
|
@ -91,12 +91,12 @@ class WebSocketsClient : protected WebSockets {
|
|||||||
void enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount);
|
void enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount);
|
||||||
void disableHeartbeat();
|
void disableHeartbeat();
|
||||||
|
|
||||||
|
bool isConnected(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
String _host;
|
String _host;
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
|
|
||||||
bool isConnected(void);
|
|
||||||
|
|
||||||
#if defined(HAS_SSL)
|
#if defined(HAS_SSL)
|
||||||
String _fingerprint;
|
String _fingerprint;
|
||||||
const char * _CA_cert;
|
const char * _CA_cert;
|
||||||
|
Reference in New Issue
Block a user