From 4910d69a405239a7e4d83742ff8115910d0a3869 Mon Sep 17 00:00:00 2001 From: "Oleg.Korshul" Date: Thu, 16 Mar 2023 22:36:48 +0500 Subject: [PATCH] Add define for reconnect timeout --- Common/Network/WebSocket/include/websocket.h | 1 + .../Network/WebSocket/src/socketio/socketio_internal.cpp | 6 ++++++ Common/Network/WebSocket/src/socketio/socketio_internal.h | 2 ++ .../WebSocket/src/socketio/socketio_internal_private.h | 7 +++++++ .../src/socketio/socketio_internal_private_no_tls.h | 7 +++++++ Common/Network/WebSocket/websocket.pri | 3 ++- 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Common/Network/WebSocket/include/websocket.h b/Common/Network/WebSocket/include/websocket.h index 5311f955d3..be13788322 100644 --- a/Common/Network/WebSocket/include/websocket.h +++ b/Common/Network/WebSocket/include/websocket.h @@ -49,6 +49,7 @@ namespace NSNetwork virtual void send(const std::string& message) = 0; virtual void close() = 0; virtual void setUrl(const std::string& url) = 0; + virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) { return false; } virtual ~IWebSocket() {} }; diff --git a/Common/Network/WebSocket/src/socketio/socketio_internal.cpp b/Common/Network/WebSocket/src/socketio/socketio_internal.cpp index c49cf3f6ed..07c53cde3d 100644 --- a/Common/Network/WebSocket/src/socketio/socketio_internal.cpp +++ b/Common/Network/WebSocket/src/socketio/socketio_internal.cpp @@ -64,5 +64,11 @@ namespace NSNetwork { delete m_internal; } + + bool CIOWebSocket::setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) + { + m_internal->setReconnectInfo(attemtCount, delay, delayMax); + return true; + } } } diff --git a/Common/Network/WebSocket/src/socketio/socketio_internal.h b/Common/Network/WebSocket/src/socketio/socketio_internal.h index d93695da39..ae08e2625e 100644 --- a/Common/Network/WebSocket/src/socketio/socketio_internal.h +++ b/Common/Network/WebSocket/src/socketio/socketio_internal.h @@ -63,6 +63,7 @@ namespace NSNetwork virtual void open(const std::map& query) = 0; virtual void send(const std::string& message) = 0; virtual void close() = 0; + virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) = 0; }; class CIOWebSocket: public CWebWorkerBase @@ -78,6 +79,7 @@ namespace NSNetwork virtual void open(const std::map& query) override; virtual void send(const std::string& message) override; virtual void close() override; + virtual bool setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax); friend class CIOWebSocket_private; friend class CIOWebSocket_private_tls; diff --git a/Common/Network/WebSocket/src/socketio/socketio_internal_private.h b/Common/Network/WebSocket/src/socketio/socketio_internal_private.h index 29f071eec3..a44ecee9b5 100644 --- a/Common/Network/WebSocket/src/socketio/socketio_internal_private.h +++ b/Common/Network/WebSocket/src/socketio/socketio_internal_private.h @@ -230,6 +230,13 @@ namespace NSNetwork m_socket.reset(); } + + virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override + { + m_socket->set_reconnect_attempts(attemtCount); + m_socket->set_reconnect_delay(delay); + m_socket->set_reconnect_delay_max(delayMax); + } }; } } diff --git a/Common/Network/WebSocket/src/socketio/socketio_internal_private_no_tls.h b/Common/Network/WebSocket/src/socketio/socketio_internal_private_no_tls.h index 920031e222..f0fccda299 100644 --- a/Common/Network/WebSocket/src/socketio/socketio_internal_private_no_tls.h +++ b/Common/Network/WebSocket/src/socketio/socketio_internal_private_no_tls.h @@ -234,6 +234,13 @@ namespace NSNetwork m_socket.reset(); } + + virtual void setReconnectInfo(const int& attemtCount, const int& delay, const int& delayMax) override + { + m_socket->set_reconnect_attempts(attemtCount); + m_socket->set_reconnect_delay(delay); + m_socket->set_reconnect_delay_max(delayMax); + } }; } } diff --git a/Common/Network/WebSocket/websocket.pri b/Common/Network/WebSocket/websocket.pri index 26629f5330..cdde0bf941 100644 --- a/Common/Network/WebSocket/websocket.pri +++ b/Common/Network/WebSocket/websocket.pri @@ -59,7 +59,8 @@ libsocketio { _WEBSOCKETPP_CPP11_CHRONO_ \ \ "SIO_TLS=1" \ - "SIO_TLS_NO=0" + "SIO_TLS_NO=0" \ + "PING_TIMEOUT_INTERVAL=20000" include($$PWD/../../3dParty/boost/boost.pri)