diff --git a/src/main.cc b/src/main.cc index ea18b8b..53f6f19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,6 +46,7 @@ class Bot { asio::any_io_executor executor; asio::steady_timer timer; asio::ip::tcp::socket socket; + std::string server; std::string name; std::string pass; std::random_device generator; @@ -63,14 +64,15 @@ class Bot { public: Bot(asio::any_io_executor executor, std::string_view name, - std::string_view pass); + std::string_view pass, std::string_view server); }; Bot::Bot(asio::any_io_executor executor, std::string_view name, - std::string_view pass) + std::string_view pass, std::string_view server) : executor{executor}, timer{executor}, socket{executor}, + server{server}, name{name}, pass{pass} { asio::co_spawn(executor, std::bind(&Bot::Protocol, this), asio::detached); @@ -78,7 +80,7 @@ Bot::Bot(asio::any_io_executor executor, std::string_view name, asio::awaitable Bot::Protocol() { asio::ip::tcp::resolver resolver{executor}; - asio::ip::tcp::resolver::query query{"94.45.241.27", "4000"}; + asio::ip::tcp::resolver::query query{server, "4000"}; auto host = co_await resolver.async_resolve(query, asio::use_awaitable); while (true) { @@ -276,13 +278,13 @@ asio::awaitable Bot::ChooseMove() { } int main(int argc, char **argv) { - if (argc < 3) { - std::cerr << "usage: " << argv[0] << " " << std::endl; + if (argc < 4) { + std::cerr << "usage: " << argv[0] << " " << std::endl; return 1; } asio::io_context context; - Bot bot{context.get_executor(), argv[1], argv[2]}; + Bot bot{context.get_executor(), argv[1], argv[2], argv[3]}; context.run(); return 0; }