diff options
Diffstat (limited to 'client/src/main.cpp')
| -rw-r--r-- | client/src/main.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/client/src/main.cpp b/client/src/main.cpp index 86a73bf..83804dd 100644 --- a/client/src/main.cpp +++ b/client/src/main.cpp @@ -40,27 +40,46 @@ int main(int argc, char* argv[]) { client.shutdown(); } - int ret = client.write(tcp::packet_t("hwid", tcp::packet_type::write, - client.session_id, - tcp::packet_id::hwid)); + int ret = + client.write(tcp::packet_t("hwid", tcp::packet_type::write, + client.session_id, tcp::packet_id::hwid)); if (ret <= 0) { io::logger->error("failed to send hwid."); client.shutdown(); } } + if (id == tcp::packet_id::login_resp) { + auto j = nlohmann::json::parse(message); + + auto res = j["result"].get<int>(); + if (res == tcp::login_result::banned) { + io::logger->error("your account is banned."); + client.shutdown(); + } + + io::logger->info("res {}", res); + } + io::logger->info("{}:{}->{} {}", packet.seq, packet.session_id, message, id); }); while (client) { + std::string u; + getline(std::cin, u); + std::string p; getline(std::cin, p); - int ret = client.write( - tcp::packet_t(p, tcp::packet_type::write, client.session_id)); + auto l = fmt::format("{},{}", u, p); + + int ret = client.write(tcp::packet_t(l, tcp::packet_type::write, + client.session_id, + tcp::packet_id::login_req)); + if (ret <= 0) { - break; + return 0; } } } |