25
25
#include " WebSockets.h"
26
26
#include " WebSocketsServer.h"
27
27
28
- WebSocketsServerCore::WebSocketsServerCore (const String& origin, const String& protocol) {
28
+ WebSocketsServerCore::WebSocketsServerCore (const String & origin, const String & protocol) {
29
29
_origin = origin;
30
30
_protocol = protocol;
31
31
_runnning = false ;
@@ -42,9 +42,9 @@ WebSocketsServerCore::WebSocketsServerCore(const String& origin, const String& p
42
42
memset (&_clients[0 ], 0x00 , (sizeof (WSclient_t) * WEBSOCKETS_SERVER_CLIENT_MAX));
43
43
}
44
44
45
- WebSocketsServer::WebSocketsServer (uint16_t port, const String& origin, const String& protocol):
46
- WebSocketsServerCore(origin, protocol) {
47
- _port = port;
45
+ WebSocketsServer::WebSocketsServer (uint16_t port, const String & origin, const String & protocol)
46
+ : WebSocketsServerCore(origin, protocol) {
47
+ _port = port;
48
48
49
49
_server = new WEBSOCKETS_NETWORK_SERVER_CLASS (port);
50
50
@@ -538,8 +538,7 @@ void WebSocketsServerCore::messageReceived(WSclient_t * client, WSopcode_t opcod
538
538
* Discard a native client
539
539
* @param client WSclient_t * ptr to the client struct contaning the native client "->tcp"
540
540
*/
541
- void WebSocketsServerCore::dropNativeClient (WSclient_t * client)
542
- {
541
+ void WebSocketsServerCore::dropNativeClient (WSclient_t * client) {
543
542
if (client->tcp ) {
544
543
if (client->tcp ->connected ()) {
545
544
#if (WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC) && (WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP32)
@@ -631,25 +630,24 @@ bool WebSocketsServerCore::clientIsConnected(WSclient_t * client) {
631
630
* Handle incoming Connection Request
632
631
*/
633
632
WSclient_t * WebSocketsServerCore::handleNewClient (WEBSOCKETS_NETWORK_CLASS * tcpClient) {
633
+ WSclient_t * client = newClient (tcpClient);
634
634
635
- WSclient_t * client = newClient (tcpClient);
636
-
637
- if (!client) {
638
- // no free space to handle client
635
+ if (!client) {
636
+ // no free space to handle client
639
637
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32)
640
638
#ifndef NODEBUG_WEBSOCKETS
641
- IPAddress ip = tcpClient->remoteIP ();
639
+ IPAddress ip = tcpClient->remoteIP ();
642
640
#endif
643
- DEBUG_WEBSOCKETS (" [WS-Server] no free space new client from %d.%d.%d.%d\n " , ip[0 ], ip[1 ], ip[2 ], ip[3 ]);
641
+ DEBUG_WEBSOCKETS (" [WS-Server] no free space new client from %d.%d.%d.%d\n " , ip[0 ], ip[1 ], ip[2 ], ip[3 ]);
644
642
#else
645
- DEBUG_WEBSOCKETS (" [WS-Server] no free space new client\n " );
643
+ DEBUG_WEBSOCKETS (" [WS-Server] no free space new client\n " );
646
644
#endif
647
- dropNativeClient (client);
648
- }
645
+ dropNativeClient (client);
646
+ }
649
647
650
- WEBSOCKETS_YIELD ();
648
+ WEBSOCKETS_YIELD ();
651
649
652
- return client;
650
+ return client;
653
651
}
654
652
655
653
/* *
@@ -971,4 +969,3 @@ void WebSocketsServer::loop(void) {
971
969
}
972
970
}
973
971
#endif
974
-
0 commit comments