26
26
#include " WebSocketsServer.h"
27
27
28
28
WebSocketsServer::WebSocketsServer (uint16_t port, String origin, String protocol) {
29
- _port = port;
30
- _origin = origin;
31
- _protocol = protocol;
32
- _runnning = false ;
33
- _pingInterval = 0 ;
34
- _pongTimeout = 0 ;
29
+ _port = port;
30
+ _origin = origin;
31
+ _protocol = protocol;
32
+ _runnning = false ;
33
+ _pingInterval = 0 ;
34
+ _pongTimeout = 0 ;
35
35
_disconnectTimeoutCount = 0 ;
36
36
37
37
_server = new WEBSOCKETS_NETWORK_SERVER_CLASS (port);
@@ -95,8 +95,8 @@ void WebSocketsServer::begin(void) {
95
95
client->cHttpLine = " " ;
96
96
#endif
97
97
98
- client->pingInterval = _pingInterval;
99
- client->pongTimeout = _pongTimeout;
98
+ client->pingInterval = _pingInterval;
99
+ client->pongTimeout = _pongTimeout;
100
100
client->disconnectTimeoutCount = _disconnectTimeoutCount;
101
101
}
102
102
@@ -489,11 +489,11 @@ bool WebSocketsServer::newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient) {
489
489
client->tcp ->readStringUntil (' \n ' , &(client->cHttpLine ), std::bind (&WebSocketsServer::handleHeader, this , client, &(client->cHttpLine )));
490
490
#endif
491
491
492
- client->pingInterval = _pingInterval;
493
- client->pongTimeout = _pongTimeout;
492
+ client->pingInterval = _pingInterval;
493
+ client->pongTimeout = _pongTimeout;
494
494
client->disconnectTimeoutCount = _disconnectTimeoutCount;
495
- client->lastPing = millis ();
496
- client->pongReceived = false ;
495
+ client->lastPing = millis ();
496
+ client->pongReceived = false ;
497
497
498
498
return true ;
499
499
break ;
@@ -657,7 +657,7 @@ void WebSocketsServer::handleNewClients(void) {
657
657
}
658
658
659
659
WEBSOCKETS_YIELD ();
660
- #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32)
660
+ #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32)
661
661
}
662
662
#endif
663
663
}
@@ -686,7 +686,7 @@ void WebSocketsServer::handleClientData(void) {
686
686
break ;
687
687
}
688
688
}
689
-
689
+
690
690
handleHBPing (client);
691
691
handleHBTimeout (client);
692
692
}
@@ -873,7 +873,7 @@ void WebSocketsServer::handleHBPing(WSclient_t * client) {
873
873
return ;
874
874
uint32_t pi = millis () - client->lastPing ;
875
875
if (pi > client->pingInterval ) {
876
- DEBUG_WEBSOCKETS (" [WS-Server][%d] sending HB ping\n " , client->num );
876
+ DEBUG_WEBSOCKETS (" [WS-Server][%d] sending HB ping\n " , client->num );
877
877
if (sendPing (client->num )) {
878
878
client->lastPing = millis ();
879
879
client->pongReceived = false ;
@@ -888,10 +888,10 @@ void WebSocketsServer::handleHBPing(WSclient_t * client) {
888
888
* @param disconnectTimeoutCount uint8_t how many timeouts before disconnect, 0=> do not disconnect
889
889
*/
890
890
void WebSocketsServer::enableHeartbeat (uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount) {
891
- _pingInterval = pingInterval;
892
- _pongTimeout = pongTimeout;
891
+ _pingInterval = pingInterval;
892
+ _pongTimeout = pongTimeout;
893
893
_disconnectTimeoutCount = disconnectTimeoutCount;
894
-
894
+
895
895
WSclient_t * client;
896
896
for (uint8_t i = 0 ; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {
897
897
client = &_clients[i];
@@ -904,10 +904,10 @@ void WebSocketsServer::enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeo
904
904
*/
905
905
void WebSocketsServer::disableHeartbeat () {
906
906
_pingInterval = 0 ;
907
-
907
+
908
908
WSclient_t * client;
909
909
for (uint8_t i = 0 ; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {
910
- client = &_clients[i];
910
+ client = &_clients[i];
911
911
client->pingInterval = 0 ;
912
912
}
913
913
}
0 commit comments