add 'connect' command & feat: disconnect-action
This commit is contained in:
parent
a33e3068c8
commit
1a7bcf9865
@ -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<DebuggingEvent> DebuggingServer::pullEvents() {
|
||||
return std::move(breakpointEvents);
|
||||
}
|
||||
|
||||
void DebuggingServer::setDisconnectAction(const std::string& action) {
|
||||
disconnectAction = action;
|
||||
}
|
||||
|
||||
@ -83,11 +83,15 @@ namespace devtools {
|
||||
|
||||
void setClient(u64id_t client);
|
||||
std::vector<DebuggingEvent> pullEvents();
|
||||
|
||||
void setDisconnectAction(const std::string& action);
|
||||
private:
|
||||
Engine& engine;
|
||||
network::Server& server;
|
||||
std::unique_ptr<ClientConnection> connection;
|
||||
bool connectionEstablished = false;
|
||||
std::vector<DebuggingEvent> breakpointEvents;
|
||||
std::string disconnectAction = "resume";
|
||||
|
||||
bool performCommand(
|
||||
const std::string& type, const dv::value& map
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user