From 2a69038c4caaf651a905d068f683972989847b08 Mon Sep 17 00:00:00 2001 From: Dimon4eg Date: Tue, 14 May 2019 21:26:37 +0300 Subject: [PATCH] add isEnabledAutomaticReconnection (#75) * add isEnabledAutomaticReconnection * test isEnabledAutomaticReconnection * rename --- ixwebsocket/IXWebSocket.cpp | 5 +++++ ixwebsocket/IXWebSocket.h | 1 + test/IXWebSocketTestConnectionDisconnection.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/ixwebsocket/IXWebSocket.cpp b/ixwebsocket/IXWebSocket.cpp index 0449e694..1146e00d 100644 --- a/ixwebsocket/IXWebSocket.cpp +++ b/ixwebsocket/IXWebSocket.cpp @@ -458,6 +458,11 @@ namespace ix _automaticReconnection = false; } + bool WebSocket::isAutomaticReconnectionEnabled() const + { + return _automaticReconnection; + } + size_t WebSocket::bufferedAmount() const { return _ws.bufferedAmount(); diff --git a/ixwebsocket/IXWebSocket.h b/ixwebsocket/IXWebSocket.h index 283b9e16..59e649d6 100644 --- a/ixwebsocket/IXWebSocket.h +++ b/ixwebsocket/IXWebSocket.h @@ -134,6 +134,7 @@ namespace ix void enableAutomaticReconnection(); void disableAutomaticReconnection(); + bool isAutomaticReconnectionEnabled() const; private: diff --git a/test/IXWebSocketTestConnectionDisconnection.cpp b/test/IXWebSocketTestConnectionDisconnection.cpp index 974f9de0..d06c30c2 100644 --- a/test/IXWebSocketTestConnectionDisconnection.cpp +++ b/test/IXWebSocketTestConnectionDisconnection.cpp @@ -96,6 +96,12 @@ namespace } }); + _webSocket.enableAutomaticReconnection(); + REQUIRE(_webSocket.isAutomaticReconnectionEnabled() == true); + + _webSocket.disableAutomaticReconnection(); + REQUIRE(_webSocket.isAutomaticReconnectionEnabled() == false); + // Start the connection _webSocket.start(); }