@@ -18,31 +18,37 @@ SocketIOclient::~SocketIOclient() {
18
18
void SocketIOclient::begin (const char * host, uint16_t port, const char * url, const char * protocol) {
19
19
WebSocketsClient::beginSocketIO (host, port, url, protocol);
20
20
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
21
+ initClient ();
21
22
}
22
23
23
24
void SocketIOclient::begin (String host, uint16_t port, String url, String protocol) {
24
25
WebSocketsClient::beginSocketIO (host, port, url, protocol);
25
26
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
27
+ initClient ();
26
28
}
27
29
#if defined(HAS_SSL)
28
30
void SocketIOclient::beginSSL (const char * host, uint16_t port, const char * url, const char * protocol) {
29
31
WebSocketsClient::beginSocketIOSSL (host, port, url, protocol);
30
32
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
33
+ initClient ();
31
34
}
32
35
33
36
void SocketIOclient::beginSSL (String host, uint16_t port, String url, String protocol) {
34
37
WebSocketsClient::beginSocketIOSSL (host, port, url, protocol);
35
38
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
39
+ initClient ();
36
40
}
37
- #if ! defined(SSL_AXTLS )
41
+ #if defined(SSL_BARESSL )
38
42
void SocketIOclient::beginSSLWithCA (const char * host, uint16_t port, const char * url, const char * CA_cert, const char * protocol) {
39
43
WebSocketsClient::beginSocketIOSSLWithCA (host, port, url, CA_cert, protocol);
40
44
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
45
+ initClient ();
41
46
}
42
47
43
48
void SocketIOclient::beginSSLWithCA (const char * host, uint16_t port, const char * url, BearSSL::X509List * CA_cert, const char * protocol) {
44
49
WebSocketsClient::beginSocketIOSSLWithCA (host, port, url, CA_cert, protocol);
45
50
WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
51
+ initClient ();
46
52
}
47
53
48
54
void SocketIOclient::setSSLClientCertKey (const char * clientCert, const char * clientPrivateKey) {
@@ -55,6 +61,18 @@ void SocketIOclient::setSSLClientCertKey(BearSSL::X509List * clientCert, BearSSL
55
61
56
62
#endif
57
63
#endif
64
+
65
+ void SocketIOclient::configureEIOping (bool disableHeartbeat) {
66
+ _disableHeartbeat = disableHeartbeat;
67
+ }
68
+
69
+ void SocketIOclient::initClient (void ) {
70
+ if (_client.cUrl .indexOf (" EIO=4" ) != -1 ) {
71
+ DEBUG_WEBSOCKETS (" [wsIOc] found EIO=4 disable EIO ping on client\n " );
72
+ configureEIOping (true );
73
+ }
74
+ }
75
+
58
76
/* *
59
77
* set callback function
60
78
* @param cbEvent SocketIOclientEvent
@@ -148,8 +166,8 @@ bool SocketIOclient::sendEVENT(String & payload) {
148
166
void SocketIOclient::loop (void ) {
149
167
WebSocketsClient::loop ();
150
168
unsigned long t = millis ();
151
- if ((t - _lastConnectionFail ) > EIO_HEARTBEAT_INTERVAL) {
152
- _lastConnectionFail = t;
169
+ if (!_disableHeartbeat && (t - _lastHeartbeat ) > EIO_HEARTBEAT_INTERVAL) {
170
+ _lastHeartbeat = t;
153
171
DEBUG_WEBSOCKETS (" [wsIOc] send ping\n " );
154
172
WebSocketsClient::sendTXT (eIOtype_PING);
155
173
}
0 commit comments