Skip to content

Commit f20fbbf

Browse files
committed
code style
1 parent 28cd929 commit f20fbbf

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

src/WebSockets.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242

4343
#ifndef NODEBUG_WEBSOCKETS
4444
#ifdef DEBUG_ESP_PORT
45-
#define DEBUG_WEBSOCKETS(...) { DEBUG_ESP_PORT.printf(__VA_ARGS__); DEBUG_ESP_PORT.flush(); }
45+
#define DEBUG_WEBSOCKETS(...) \
46+
{ \
47+
DEBUG_ESP_PORT.printf(__VA_ARGS__); \
48+
DEBUG_ESP_PORT.flush(); \
49+
}
4650
#else
4751
//#define DEBUG_WEBSOCKETS(...) os_printf( __VA_ARGS__ )
4852
#endif

src/WebSockets4WebServer.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,18 @@
3030

3131
#if WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266 && WEBSERVER_HAS_HOOK
3232

33-
class WebSockets4WebServer: public WebSocketsServerCore {
33+
class WebSockets4WebServer : public WebSocketsServerCore {
3434
public:
35-
36-
WebSockets4WebServer(const String& origin = "", const String& protocol = "arduino"):
37-
WebSocketsServerCore(origin, protocol)
38-
{
35+
WebSockets4WebServer(const String & origin = "", const String & protocol = "arduino")
36+
: WebSocketsServerCore(origin, protocol) {
3937
begin();
4038
}
4139

42-
ESP8266WebServer::HookFunction hookForWebserver (const String& wsRootDir, WebSocketServerEvent event)
43-
{
40+
ESP8266WebServer::HookFunction hookForWebserver(const String & wsRootDir, WebSocketServerEvent event) {
4441
onEvent(event);
4542

46-
return [&, wsRootDir](const String & method, const String & url, WiFiClient * tcpClient, ESP8266WebServer::ContentTypeFunction contentType)
47-
{
48-
if (!(method == "GET" && url.indexOf(wsRootDir) == 0)) {
43+
return [&, wsRootDir](const String & method, const String & url, WiFiClient * tcpClient, ESP8266WebServer::ContentTypeFunction contentType) {
44+
if(!(method == "GET" && url.indexOf(wsRootDir) == 0)) {
4945
return ESP8266WebServer::CLIENT_REQUEST_CAN_CONTINUE;
5046
}
5147

@@ -55,8 +51,7 @@ class WebSockets4WebServer: public WebSocketsServerCore {
5551
// Then initialize a new WSclient_t (like in WebSocketsServer::handleNewClient())
5652
WSclient_t * client = handleNewClient(newTcpClient);
5753

58-
if (client)
59-
{
54+
if(client) {
6055
// give "GET <url>"
6156
String headerLine;
6257
headerLine.reserve(url.length() + 5);
@@ -71,6 +66,6 @@ class WebSockets4WebServer: public WebSocketsServerCore {
7166
}
7267
};
7368

74-
#endif // WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266 && WEBSERVER_HAS_HOOK
69+
#endif // WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266 && WEBSERVER_HAS_HOOK
7570

76-
#endif // __WEBSOCKETS4WEBSERVER_H
71+
#endif // __WEBSOCKETS4WEBSERVER_H

src/WebSocketsServer.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333

3434
class WebSocketsServerCore : protected WebSockets {
3535
public:
36-
37-
WebSocketsServerCore(const String& origin = "", const String& protocol = "arduino");
36+
WebSocketsServerCore(const String & origin = "", const String & protocol = "arduino");
3837
virtual ~WebSocketsServerCore(void);
3938

4039
void begin(void);
@@ -96,7 +95,7 @@ class WebSocketsServerCore : protected WebSockets {
9695
#endif
9796

9897
#if(WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC)
99-
void loop(void); // handle client data only
98+
void loop(void); // handle client data only
10099
#endif
101100

102101
protected:
@@ -207,35 +206,32 @@ class WebSocketsServerCore : protected WebSockets {
207206
/**
208207
* drop native tcp connection (client->tcp)
209208
*/
210-
void dropNativeClient (WSclient_t * client);
209+
void dropNativeClient(WSclient_t * client);
211210

212211
private:
213212
/*
214213
* returns an indicator whether the given named header exists in the configured _mandatoryHttpHeaders collection
215214
* @param headerName String ///< the name of the header being checked
216215
*/
217216
bool hasMandatoryHeader(String headerName);
218-
219217
};
220218

221-
class WebSocketsServer: public WebSocketsServerCore {
219+
class WebSocketsServer : public WebSocketsServerCore {
222220
public:
223-
224-
WebSocketsServer(uint16_t port, const String& origin = "", const String& protocol = "arduino");
221+
WebSocketsServer(uint16_t port, const String & origin = "", const String & protocol = "arduino");
225222
virtual ~WebSocketsServer(void);
226223

227224
void begin(void);
228225
void close(void);
229226

230227
#if(WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC)
231-
void loop(void); // handle incoming client and client data
228+
void loop(void); // handle incoming client and client data
232229
#else
233230
// Async interface not need a loop call
234231
void loop(void) __attribute__((deprecated)) {}
235232
#endif
236233

237234
protected:
238-
239235
#if(WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC)
240236
void handleNewClients(void);
241237
#endif

0 commit comments

Comments
 (0)