fix code style

This commit is contained in:
Links
2018-05-12 11:27:03 +02:00
parent e8c0d775fb
commit a796079b0c
2 changed files with 175 additions and 181 deletions

View File

@ -25,7 +25,6 @@
#include "WebSockets.h" #include "WebSockets.h"
#include "WebSocketsClient.h" #include "WebSocketsClient.h"
WebSocketsClient::WebSocketsClient() { WebSocketsClient::WebSocketsClient() {
_cbEvent = NULL; _cbEvent = NULL;
_client.num = 0; _client.num = 0;
@ -252,7 +251,6 @@ bool WebSocketsClient::sendPing(String & payload) {
return sendPing((uint8_t *) payload.c_str(), payload.length()); return sendPing((uint8_t *) payload.c_str(), payload.length());
} }
/** /**
* disconnect one client * disconnect one client
* @param num uint8_t client id * @param num uint8_t client id
@ -273,7 +271,7 @@ void WebSocketsClient::setAuthorization(const char * user, const char * password
String auth = user; String auth = user;
auth += ":"; auth += ":";
auth += password; auth += password;
_client.base64Authorization = base64_encode((uint8_t *)auth.c_str(), auth.length()); _client.base64Authorization = base64_encode((uint8_t *) auth.c_str(), auth.length());
} }
} }
@ -297,7 +295,6 @@ void WebSocketsClient::setExtraHeaders(const char * extraHeaders) {
_client.extraHeaders = extraHeaders; _client.extraHeaders = extraHeaders;
} }
/** /**
* set the reconnect Interval * set the reconnect Interval
* how long to wait after a connection initiate failed * how long to wait after a connection initiate failed
@ -429,8 +426,7 @@ void WebSocketsClient::handleClientData(void) {
int len = _client.tcp->available(); int len = _client.tcp->available();
if(len > 0) { if(len > 0) {
switch(_client.status) { switch(_client.status) {
case WSC_HEADER: case WSC_HEADER: {
{
String headerLine = _client.tcp->readStringUntil('\n'); String headerLine = _client.tcp->readStringUntil('\n');
handleHeader(&_client, &headerLine); handleHeader(&_client, &headerLine);
} }
@ -449,7 +445,6 @@ void WebSocketsClient::handleClientData(void) {
} }
#endif #endif
/** /**
* send the WebSocket header to Server * send the WebSocket header to Server
* @param client WSclient_t * ptr to the client struct * @param client WSclient_t * ptr to the client struct
@ -500,19 +495,19 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
if(client->cProtocol.length() > 0) { if(client->cProtocol.length() > 0) {
handshake += WEBSOCKETS_STRING("Sec-WebSocket-Protocol: "); handshake += WEBSOCKETS_STRING("Sec-WebSocket-Protocol: ");
handshake +=client->cProtocol + NEW_LINE; handshake += client->cProtocol + NEW_LINE;
} }
if(client->cExtensions.length() > 0) { if(client->cExtensions.length() > 0) {
handshake += WEBSOCKETS_STRING("Sec-WebSocket-Extensions: "); handshake += WEBSOCKETS_STRING("Sec-WebSocket-Extensions: ");
handshake +=client->cExtensions + NEW_LINE; handshake += client->cExtensions + NEW_LINE;
} }
} else { } else {
handshake += WEBSOCKETS_STRING("Connection: keep-alive\r\n"); handshake += WEBSOCKETS_STRING("Connection: keep-alive\r\n");
} }
// add extra headers; by default this includes "Origin: file://" // add extra headers; by default this includes "Origin: file://"
if (client->extraHeaders) { if(client->extraHeaders) {
handshake += client->extraHeaders + NEW_LINE; handshake += client->extraHeaders + NEW_LINE;
} }
@ -530,8 +525,8 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
handshake += NEW_LINE; handshake += NEW_LINE;
DEBUG_WEBSOCKETS("[WS-Client][sendHeader] handshake %s", (uint8_t*)handshake.c_str()); DEBUG_WEBSOCKETS("[WS-Client][sendHeader] handshake %s", (uint8_t* )handshake.c_str());
write(client, (uint8_t*)handshake.c_str(), handshake.length()); write(client, (uint8_t*) handshake.c_str(), handshake.length());
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC)
client->tcp->readStringUntil('\n', &(client->cHttpLine), std::bind(&WebSocketsClient::handleHeader, this, client, &(client->cHttpLine))); client->tcp->readStringUntil('\n', &(client->cHttpLine), std::bind(&WebSocketsClient::handleHeader, this, client, &(client->cHttpLine)));
@ -711,7 +706,6 @@ void WebSocketsClient::connectedCb() {
} }
void WebSocketsClient::connectFailedCb() { void WebSocketsClient::connectFailedCb() {
DEBUG_WEBSOCKETS("[WS-Client] connection to %s:%u Faild\n", _host.c_str(), _port); DEBUG_WEBSOCKETS("[WS-Client] connection to %s:%u Faild\n", _host.c_str(), _port);
} }

View File

@ -758,7 +758,7 @@ void WebSocketsServer::handleHeader(WSclient_t * client, String * headerLine) {
client->base64Authorization = headerValue; client->base64Authorization = headerValue;
} else { } else {
client->cHttpHeadersValid &= execHttpHeaderValidation(headerName, headerValue); client->cHttpHeadersValid &= execHttpHeaderValidation(headerName, headerValue);
if (_mandatoryHttpHeaderCount > 0 && hasMandatoryHeader(headerName)) { if(_mandatoryHttpHeaderCount > 0 && hasMandatoryHeader(headerName)) {
client->cMandatoryHeadersCount++; client->cMandatoryHeadersCount++;
} }
} }