diff --git a/src/devtools/DebuggingServer.cpp b/src/devtools/DebuggingServer.cpp index 2baebf47..b6a67c7e 100644 --- a/src/devtools/DebuggingServer.cpp +++ b/src/devtools/DebuggingServer.cpp @@ -139,8 +139,9 @@ bool DebuggingServer::update() { std::string message = connection->read(); if (message.empty()) { if (!connection->alive()) { + bool status = performCommand(disconnectAction, dv::object()); connection.reset(); - return true; + return status; } return false; } @@ -165,6 +166,15 @@ bool DebuggingServer::update() { bool DebuggingServer::performCommand( const std::string& type, const dv::value& map ) { + if (type == "connect" && !connectionEstablished) { + map.at("disconnect-action").get(disconnectAction); + connectionEstablished = true; + logger.info() << "client connection established"; + connection->sendResponse("success"); + } + if (!connectionEstablished) { + return false; + } if (type == "terminate") { engine.quit(); connection->sendResponse("success"); @@ -272,3 +282,7 @@ void DebuggingServer::setClient(u64id_t client) { std::vector DebuggingServer::pullEvents() { return std::move(breakpointEvents); } + +void DebuggingServer::setDisconnectAction(const std::string& action) { + disconnectAction = action; +} diff --git a/src/devtools/DebuggingServer.hpp b/src/devtools/DebuggingServer.hpp index 13c9282b..533453d7 100644 --- a/src/devtools/DebuggingServer.hpp +++ b/src/devtools/DebuggingServer.hpp @@ -83,11 +83,15 @@ namespace devtools { void setClient(u64id_t client); std::vector pullEvents(); + + void setDisconnectAction(const std::string& action); private: Engine& engine; network::Server& server; std::unique_ptr connection; + bool connectionEstablished = false; std::vector breakpointEvents; + std::string disconnectAction = "resume"; bool performCommand( const std::string& type, const dv::value& map