diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp index 8e361031..39bd7d5e 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.cpp @@ -185,6 +185,14 @@ void GRPCClient::connectToServer(QString const &configDir, GRPCConfig const &con } +//**************************************************************************************************************************************************** +/// \return true if the gRPC client is connected to the server. +//**************************************************************************************************************************************************** +bool GRPCClient::isConnected() const { + return stub_.get(); +} + + //**************************************************************************************************************************************************** /// \param[in] clientConfigPath The path to the gRPC client config path.- /// \param[in] serverToken The token obtained from the server config file. @@ -397,6 +405,8 @@ grpc::Status GRPCClient::setIsDoHEnabled(bool enabled) { //**************************************************************************************************************************************************** grpc::Status GRPCClient::quit() { // quitting will shut down the gRPC service, to we may get an 'Unavailable' response for the call + if (!this->isConnected()) + return Status::OK; // We're not even connected, we return OK. This maybe be an attempt to do 'a proper' shutdown after an unrecoverable error. return this->logGRPCCallStatus(stub_->Quit(this->clientContext().get(), empty, &empty), __FUNCTION__, { StatusCode::UNAVAILABLE }); } diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h index 9bae4e14..aa69b165 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCClient.h @@ -60,6 +60,7 @@ public: // member functions. GRPCClient &operator=(GRPCClient &&) = delete; ///< Disabled move assignment operator. void setLog(Log *log); ///< Set the log for the client. void connectToServer(QString const &configDir, GRPCConfig const &config, class ProcessMonitor *serverProcess); ///< Establish connection to the gRPC server. + bool isConnected() const; ///< Check whether the gRPC client is connected to the server. grpc::Status checkTokens(QString const &clientConfigPath, QString &outReturnedClientToken); ///< Performs a token check. grpc::Status addLogEntry(Log::Level level, QString const &package, QString const &message); ///< Performs the "AddLogEntry" gRPC call.