Browse Source

simplify main, also print more information

master
Jørgen Lien Sellæg 9 years ago
parent
commit
dff2e05342
  1. 26
      toREST/src/main.cxx

26
toREST/src/main.cxx

@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
tr::ws::on_close(session, connection, status, reason); tr::ws::on_close(session, connection, status, reason);
}; };
{
std::thread http_thread([&http_server]() { std::thread http_thread([&http_server]() {
http_server.start(); http_server.start();
}); });
@ -101,19 +101,29 @@ int main(int argc, char *argv[]) {
std::cout << "HTTP/1.1 websocket server listening on port " << config.ws_port << std::endl; std::cout << "HTTP/1.1 websocket server listening on port " << config.ws_port << std::endl;
std::string input; std::string input;
while (input != "q") { while (input != "q") {
std::getline(std::cin, input); std::getline(std::cin, input);
if (input == "q") {
std::cout << "Stopping server..." << std::endl;
http_server.stop(); // TODO check if throws
ws_server.stop();
std::cout << "Server stopped" << std::endl;
break;
}
} }
std::cout << "stopping http server..." << std::endl;
http_server.stop();
std::cout << "stopping ws server..." << std::endl;
ws_server.stop();
http_thread.join(); http_thread.join();
std::cout << "the http server was stopped." << std::endl;
ws_thread.join(); ws_thread.join();
std::cout << "the ws server was stopped." << std::endl;
}
std::cout << "stopping torrents..." << std::endl;
{
auto session_proxy = session.abort();
}
std::cout << "the torrent session was stopped." << std::endl;
return 0; return 0;
}; };

Loading…
Cancel
Save