diff --git a/src/WebSockets.h b/src/WebSockets.h index 10434fe..0d9b707 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -61,7 +61,7 @@ // moves all Header strings to Flash (~300 Byte) //#define WEBSOCKETS_SAVE_RAM -#if defined(ESP8266) +#if defined(ESP8266) #define WEBSOCKETS_YIELD() delay(0) #elif defined(ESP32) #define WEBSOCKETS_YIELD() yield() diff --git a/src/WebSocketsClient.cpp b/src/WebSocketsClient.cpp index 179c272..2e7f4b2 100644 --- a/src/WebSocketsClient.cpp +++ b/src/WebSocketsClient.cpp @@ -30,7 +30,7 @@ WebSocketsClient::WebSocketsClient() { _client.num = 0; _client.cIsClient = true; _client.extraHeaders = WEBSOCKETS_STRING("Origin: file://"); - _reconnectInterval = 500; + _reconnectInterval = 500; } WebSocketsClient::~WebSocketsClient() { diff --git a/src/WebSocketsServer.cpp b/src/WebSocketsServer.cpp index 16ee1c8..a682ec9 100644 --- a/src/WebSocketsServer.cpp +++ b/src/WebSocketsServer.cpp @@ -26,12 +26,12 @@ #include "WebSocketsServer.h" WebSocketsServer::WebSocketsServer(uint16_t port, String origin, String protocol) { - _port = port; - _origin = origin; - _protocol = protocol; - _runnning = false; - _pingInterval = 0; - _pongTimeout = 0; + _port = port; + _origin = origin; + _protocol = protocol; + _runnning = false; + _pingInterval = 0; + _pongTimeout = 0; _disconnectTimeoutCount = 0; _server = new WEBSOCKETS_NETWORK_SERVER_CLASS(port); @@ -95,8 +95,8 @@ void WebSocketsServer::begin(void) { client->cHttpLine = ""; #endif - client->pingInterval = _pingInterval; - client->pongTimeout = _pongTimeout; + client->pingInterval = _pingInterval; + client->pongTimeout = _pongTimeout; client->disconnectTimeoutCount = _disconnectTimeoutCount; } @@ -489,11 +489,11 @@ bool WebSocketsServer::newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient) { client->tcp->readStringUntil('\n', &(client->cHttpLine), std::bind(&WebSocketsServer::handleHeader, this, client, &(client->cHttpLine))); #endif - client->pingInterval = _pingInterval; - client->pongTimeout = _pongTimeout; + client->pingInterval = _pingInterval; + client->pongTimeout = _pongTimeout; client->disconnectTimeoutCount = _disconnectTimeoutCount; - client->lastPing = millis(); - client->pongReceived = false; + client->lastPing = millis(); + client->pongReceived = false; return true; break; @@ -657,7 +657,7 @@ void WebSocketsServer::handleNewClients(void) { } WEBSOCKETS_YIELD(); -#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32) +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32) } #endif } @@ -686,7 +686,7 @@ void WebSocketsServer::handleClientData(void) { break; } } - + handleHBPing(client); handleHBTimeout(client); } @@ -873,7 +873,7 @@ void WebSocketsServer::handleHBPing(WSclient_t * client) { return; uint32_t pi = millis() - client->lastPing; if(pi > client->pingInterval) { - DEBUG_WEBSOCKETS("[WS-Server][%d] sending HB ping\n", client->num); + DEBUG_WEBSOCKETS("[WS-Server][%d] sending HB ping\n", client->num); if(sendPing(client->num)) { client->lastPing = millis(); client->pongReceived = false; @@ -888,10 +888,10 @@ void WebSocketsServer::handleHBPing(WSclient_t * client) { * @param disconnectTimeoutCount uint8_t how many timeouts before disconnect, 0=> do not disconnect */ void WebSocketsServer::enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount) { - _pingInterval = pingInterval; - _pongTimeout = pongTimeout; + _pingInterval = pingInterval; + _pongTimeout = pongTimeout; _disconnectTimeoutCount = disconnectTimeoutCount; - + WSclient_t * client; for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { client = &_clients[i]; @@ -904,10 +904,10 @@ void WebSocketsServer::enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeo */ void WebSocketsServer::disableHeartbeat() { _pingInterval = 0; - + WSclient_t * client; for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { - client = &_clients[i]; + client = &_clients[i]; client->pingInterval = 0; } } \ No newline at end of file diff --git a/src/WebSocketsServer.h b/src/WebSocketsServer.h index 74ea85f..19c934d 100644 --- a/src/WebSocketsServer.h +++ b/src/WebSocketsServer.h @@ -91,7 +91,7 @@ class WebSocketsServer : protected WebSockets { void setAuthorization(const char * auth); int connectedClients(bool ping = false); - + void enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount); void disableHeartbeat(); @@ -115,7 +115,7 @@ class WebSocketsServer : protected WebSockets { WebSocketServerHttpHeaderValFunc _httpHeaderValidationFunc; bool _runnning; - + uint32_t _pingInterval; uint32_t _pongTimeout; uint8_t _disconnectTimeoutCount; @@ -133,7 +133,7 @@ class WebSocketsServer : protected WebSockets { #endif void handleHeader(WSclient_t * client, String * headerLine); - + void handleHBPing(WSclient_t * client); // send ping in specified intervals /**