Skip to content

Commit

Permalink
feat: add machine interface for rpc cli
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Oct 21, 2023
1 parent 83723bc commit 8bcdda2
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions source/MaaRpc/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

std::mutex mutex;
std::condition_variable cv;
bool mi = false;
bool quiet = false;
bool quit = false;

Expand Down Expand Up @@ -40,6 +41,9 @@ int main(int argc, char* argv[])
else if (opt == "-q") {
quiet = true;
}
else if (opt == "-mi") {
mi = true;
}
else if (opt.starts_with("-p=")) {
port = std::stoi(opt.substr(3));
}
Expand All @@ -57,13 +61,28 @@ int main(int argc, char* argv[])

std::unique_lock<std::mutex> lock(mutex);
if (!quiet) {
std::cout << "Server listening on " << server_address << std::endl;
if (mi) {
std::cout << "[MAARPC]START|" << server_address << std::endl;
}
else {
std::cout << "Server listening on " << server_address << std::endl;
}
}
cv.wait(lock, []() { return quit; });

std::cout << "Start stopping" << std::endl;
if (mi) {
std::cout << "[MAARPC]STOP" << std::endl;
}
else {
std::cout << "Start stopping" << std::endl;
}
MaaRpcStop();

std::cout << "Exit" << std::endl;
if (mi) {
std::cout << "[MAARPC]EXIT" << std::endl;
}
else {
std::cout << "Exit" << std::endl;
}
return 0;
}

0 comments on commit 8bcdda2

Please sign in to comment.