aboutsummaryrefslogtreecommitdiff
path: root/client/src/main.cpp
diff options
context:
space:
mode:
authorauth <[email protected]>2020-07-13 23:05:20 +0200
committerauth <[email protected]>2020-07-13 23:05:20 +0200
commite177151308cbdfb2b96119389cf5bf7c2659b94e (patch)
tree7e5737aca17322bf3d39ee5643b3ae2d5deea8f3 /client/src/main.cpp
parentSmall changes. (diff)
downloadloader-e177151308cbdfb2b96119389cf5bf7c2659b94e.tar.xz
loader-e177151308cbdfb2b96119389cf5bf7c2659b94e.zip
Forum integration.
Added separate packet ids for login request/response. Added login responses. Small code changes.
Diffstat (limited to 'client/src/main.cpp')
-rw-r--r--client/src/main.cpp31
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;
}
}
}