@@ -18,31 +18,37 @@ SocketIOclient::~SocketIOclient() {
1818void SocketIOclient::begin (const char * host, uint16_t port, const char * url, const char * protocol) {
1919 WebSocketsClient::beginSocketIO (host, port, url, protocol);
2020 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
21+ initClient ();
2122}
2223
2324void SocketIOclient::begin (String host, uint16_t port, String url, String protocol) {
2425 WebSocketsClient::beginSocketIO (host, port, url, protocol);
2526 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
27+ initClient ();
2628}
2729#if defined(HAS_SSL)
2830void SocketIOclient::beginSSL (const char * host, uint16_t port, const char * url, const char * protocol) {
2931 WebSocketsClient::beginSocketIOSSL (host, port, url, protocol);
3032 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
33+ initClient ();
3134}
3235
3336void SocketIOclient::beginSSL (String host, uint16_t port, String url, String protocol) {
3437 WebSocketsClient::beginSocketIOSSL (host, port, url, protocol);
3538 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
39+ initClient ();
3640}
37- #if ! defined(SSL_AXTLS )
41+ #if defined(SSL_BARESSL )
3842void SocketIOclient::beginSSLWithCA (const char * host, uint16_t port, const char * url, const char * CA_cert, const char * protocol) {
3943 WebSocketsClient::beginSocketIOSSLWithCA (host, port, url, CA_cert, protocol);
4044 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
45+ initClient ();
4146}
4247
4348void SocketIOclient::beginSSLWithCA (const char * host, uint16_t port, const char * url, BearSSL::X509List * CA_cert, const char * protocol) {
4449 WebSocketsClient::beginSocketIOSSLWithCA (host, port, url, CA_cert, protocol);
4550 WebSocketsClient::enableHeartbeat (60 * 1000 , 90 * 1000 , 5 );
51+ initClient ();
4652}
4753
4854void SocketIOclient::setSSLClientCertKey (const char * clientCert, const char * clientPrivateKey) {
@@ -55,6 +61,18 @@ void SocketIOclient::setSSLClientCertKey(BearSSL::X509List * clientCert, BearSSL
5561
5662#endif
5763#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+
5876/* *
5977 * set callback function
6078 * @param cbEvent SocketIOclientEvent
@@ -148,8 +166,8 @@ bool SocketIOclient::sendEVENT(String & payload) {
148166void SocketIOclient::loop (void ) {
149167 WebSocketsClient::loop ();
150168 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;
153171 DEBUG_WEBSOCKETS (" [wsIOc] send ping\n " );
154172 WebSocketsClient::sendTXT (eIOtype_PING);
155173 }
0 commit comments