diff --git a/src/ConnectionHandlerInterface.cpp b/src/ConnectionHandlerInterface.cpp index e206b85..bfb0e8e 100644 --- a/src/ConnectionHandlerInterface.cpp +++ b/src/ConnectionHandlerInterface.cpp @@ -78,7 +78,7 @@ NetworkConnectionState ConnectionHandler::updateConnectionState() { case NetworkConnectionState::CONNECTED: next_net_connection_state = update_handleConnected (); break; case NetworkConnectionState::DISCONNECTING: next_net_connection_state = update_handleDisconnecting(); break; case NetworkConnectionState::DISCONNECTED: next_net_connection_state = update_handleDisconnected (); break; - case NetworkConnectionState::ERROR: break; + case NetworkConnectionState::ERROR: next_net_connection_state = update_handleError (); break; case NetworkConnectionState::CLOSED: break; } @@ -88,6 +88,15 @@ NetworkConnectionState ConnectionHandler::updateConnectionState() { return next_net_connection_state; } +NetworkConnectionState ConnectionHandler::update_handleError() +{ + if (_keep_alive) { + return NetworkConnectionState::INIT; + } + + return NetworkConnectionState::ERROR; +} + void ConnectionHandler::updateCallback(NetworkConnectionState next_net_connection_state) { /* Check the next state to determine the kind of state conversion which has occurred (and call the appropriate callback) */ diff --git a/src/ConnectionHandlerInterface.h b/src/ConnectionHandlerInterface.h index a4d3fc6..3e7a461 100644 --- a/src/ConnectionHandlerInterface.h +++ b/src/ConnectionHandlerInterface.h @@ -124,6 +124,7 @@ class ConnectionHandler { virtual NetworkConnectionState update_handleConnected () = 0; virtual NetworkConnectionState update_handleDisconnecting() = 0; virtual NetworkConnectionState update_handleDisconnected () = 0; + virtual NetworkConnectionState update_handleError (); models::NetworkSetting _settings; diff --git a/src/GenericConnectionHandler.cpp b/src/GenericConnectionHandler.cpp index bc8005a..9725e68 100644 --- a/src/GenericConnectionHandler.cpp +++ b/src/GenericConnectionHandler.cpp @@ -180,3 +180,7 @@ NetworkConnectionState GenericConnectionHandler::update_handleDisconnecting() { NetworkConnectionState GenericConnectionHandler::update_handleDisconnected() { return _ch != nullptr ? _ch->update_handleDisconnected() : NetworkConnectionState::INIT; } + +NetworkConnectionState GenericConnectionHandler::update_handleError() { + return _ch != nullptr ? _ch->update_handleError() : NetworkConnectionState::INIT; +} diff --git a/src/GenericConnectionHandler.h b/src/GenericConnectionHandler.h index 9145f12..c9b2f38 100644 --- a/src/GenericConnectionHandler.h +++ b/src/GenericConnectionHandler.h @@ -69,6 +69,7 @@ class GenericConnectionHandler : public ConnectionHandler NetworkConnectionState update_handleConnected () override; NetworkConnectionState update_handleDisconnecting() override; NetworkConnectionState update_handleDisconnected () override; + NetworkConnectionState update_handleError () override; private: