diff --git a/src/WebSockets.cpp b/src/WebSockets.cpp index 13e1b32..49f5480 100644 --- a/src/WebSockets.cpp +++ b/src/WebSockets.cpp @@ -42,13 +42,13 @@ extern "C" { #include #if ESP_IDF_VERSION_MAJOR >= 4 - #if ( ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(1, 0, 6) ) - #include "sha/sha_parallel_engine.h" - #else - #include - #endif +#if(ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(1, 0, 6)) +#include "sha/sha_parallel_engine.h" #else - #include +#include +#endif +#else +#include #endif #else @@ -472,7 +472,7 @@ void WebSockets::handleWebsocketPayloadCb(WSclient_t * client, bool ok, uint8_t payload[header->payloadLen] = 0x00; if(header->mask) { - //decode XOR + // decode XOR for(size_t i = 0; i < header->payloadLen; i++) { payload[i] = (payload[i] ^ header->maskKey[i % 4]); } @@ -526,7 +526,7 @@ void WebSockets::handleWebsocketPayloadCb(WSclient_t * client, bool ok, uint8_t // reset input client->cWsRXsize = 0; #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) - //register callback for next message + // register callback for next message handleWebsocketWaitFor(client, 2); #endif @@ -644,9 +644,9 @@ bool WebSockets::readCb(WSclient_t * client, uint8_t * out, size_t n, WSreadWait t = millis(); out += len; n -= len; - //DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); + // DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); } else { - //DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); + // DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); } if(n > 0) { WEBSOCKETS_YIELD(); @@ -698,7 +698,7 @@ size_t WebSockets::write(WSclient_t * client, uint8_t * out, size_t n) { out += len; n -= len; total += len; - //DEBUG_WEBSOCKETS("write %d left %d!\n", len, n); + // DEBUG_WEBSOCKETS("write %d left %d!\n", len, n); } else { DEBUG_WEBSOCKETS("WS write %d failed left %d!\n", len, n); } diff --git a/src/WebSockets.h b/src/WebSockets.h index b182bd5..60c13d9 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -86,7 +86,7 @@ #define WEBSOCKETS_YIELD_MORE() #else -//atmega328p has only 2KB ram! +// atmega328p has only 2KB ram! #define WEBSOCKETS_MAX_DATA_SIZE (1024) // moves all Header strings to Flash #define WEBSOCKETS_SAVE_RAM diff --git a/src/WebSocketsClient.h b/src/WebSocketsClient.h index efa7631..6cc98d4 100644 --- a/src/WebSocketsClient.h +++ b/src/WebSocketsClient.h @@ -154,11 +154,11 @@ class WebSocketsClient : protected WebSockets { #endif /** - * called for sending a Event to the app - * @param type WStype_t - * @param payload uint8_t * - * @param length size_t - */ + * called for sending a Event to the app + * @param type WStype_t + * @param payload uint8_t * + * @param length size_t + */ virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) { if(_cbEvent) { _cbEvent(type, payload, length); diff --git a/src/WebSocketsServer.cpp b/src/WebSocketsServer.cpp index 81734ba..c206363 100644 --- a/src/WebSocketsServer.cpp +++ b/src/WebSocketsServer.cpp @@ -621,8 +621,8 @@ WSclient_t * WebSocketsServerCore::handleNewClient(WEBSOCKETS_NETWORK_CLASS * tc #endif // no client! => create dummy! WSclient_t dummy = WSclient_t(); - client = & dummy; - client->tcp = tcpClient; + client = &dummy; + client->tcp = tcpClient; dropNativeClient(client); } @@ -663,7 +663,7 @@ void WebSocketsServerCore::handleClientData(void) { if(clientIsConnected(client)) { int len = client->tcp->available(); if(len > 0) { - //DEBUG_WEBSOCKETS("[WS-Server][%d][handleClientData] len: %d\n", client->num, len); + // DEBUG_WEBSOCKETS("[WS-Server][%d][handleClientData] len: %d\n", client->num, len); switch(client->status) { case WSC_HEADER: { String headerLine = client->tcp->readStringUntil('\n'); @@ -717,7 +717,7 @@ void WebSocketsServerCore::handleHeader(WSclient_t * client, String * headerLine // cut URL out client->cUrl = headerLine->substring(4, headerLine->indexOf(' ', 4)); - //reset non-websocket http header validation state for this client + // reset non-websocket http header validation state for this client client->cHttpHeadersValid = true; client->cMandatoryHeadersCount = 0; diff --git a/src/WebSocketsServer.h b/src/WebSocketsServer.h index 5bdcd04..543cba9 100644 --- a/src/WebSocketsServer.h +++ b/src/WebSocketsServer.h @@ -132,10 +132,10 @@ class WebSocketsServerCore : protected WebSockets { void handleHBPing(WSclient_t * client); // send ping in specified intervals /** - * called if a non Websocket connection is coming in. - * Note: can be override - * @param client WSclient_t * ptr to the client struct - */ + * called if a non Websocket connection is coming in. + * Note: can be override + * @param client WSclient_t * ptr to the client struct + */ virtual void handleNonWebsocketConnection(WSclient_t * client) { DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] no Websocket connection close.\n", client->num); client->tcp->write( @@ -151,10 +151,10 @@ class WebSocketsServerCore : protected WebSockets { } /** - * called if a non Authorization connection is coming in. - * Note: can be override - * @param client WSclient_t * ptr to the client struct - */ + * called if a non Authorization connection is coming in. + * Note: can be override + * @param client WSclient_t * ptr to the client struct + */ virtual void handleAuthorizationFailed(WSclient_t * client) { client->tcp->write( "HTTP/1.1 401 Unauthorized\r\n" @@ -170,12 +170,12 @@ class WebSocketsServerCore : protected WebSockets { } /** - * called for sending a Event to the app - * @param num uint8_t - * @param type WStype_t - * @param payload uint8_t * - * @param length size_t - */ + * called for sending a Event to the app + * @param num uint8_t + * @param type WStype_t + * @param payload uint8_t * + * @param length size_t + */ virtual void runCbEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { if(_cbEvent) { _cbEvent(num, type, payload, length); @@ -183,19 +183,19 @@ class WebSocketsServerCore : protected WebSockets { } /* - * Called at client socket connect handshake negotiation time for each http header that is not - * a websocket specific http header (not Connection, Upgrade, Sec-WebSocket-*) - * If the custom httpHeaderValidationFunc returns false for any headerName / headerValue passed, the - * socket negotiation is considered invalid and the upgrade to websockets request is denied / rejected - * This mechanism can be used to enable custom authentication schemes e.g. test the value - * of a session cookie to determine if a user is logged on / authenticated - */ + * Called at client socket connect handshake negotiation time for each http header that is not + * a websocket specific http header (not Connection, Upgrade, Sec-WebSocket-*) + * If the custom httpHeaderValidationFunc returns false for any headerName / headerValue passed, the + * socket negotiation is considered invalid and the upgrade to websockets request is denied / rejected + * This mechanism can be used to enable custom authentication schemes e.g. test the value + * of a session cookie to determine if a user is logged on / authenticated + */ virtual bool execHttpHeaderValidation(String headerName, String headerValue) { if(_httpHeaderValidationFunc) { - //return the value of the custom http header validation function + // return the value of the custom http header validation function return _httpHeaderValidationFunc(headerName, headerValue); } - //no custom http header validation so just assume all is good + // no custom http header validation so just assume all is good return true; } @@ -205,14 +205,14 @@ class WebSocketsServerCore : protected WebSockets { /** * drop native tcp connection (client->tcp) - */ + */ void dropNativeClient(WSclient_t * client); private: /* - * returns an indicator whether the given named header exists in the configured _mandatoryHttpHeaders collection - * @param headerName String ///< the name of the header being checked - */ + * returns an indicator whether the given named header exists in the configured _mandatoryHttpHeaders collection + * @param headerName String ///< the name of the header being checked + */ bool hasMandatoryHeader(String headerName); };