aboutsummaryrefslogtreecommitdiff
path: root/client/src/main.cpp
diff options
context:
space:
mode:
authoralpine <[email protected]>2020-06-04 16:13:19 +0200
committeralpine <[email protected]>2020-06-04 16:13:19 +0200
commit28f66dee8a9fe49aadb5c1d67de48d9232363963 (patch)
tree00f6bfd0c2120d005c833301830d167b0753feb3 /client/src/main.cpp
downloadloader-28f66dee8a9fe49aadb5c1d67de48d9232363963.tar.xz
loader-28f66dee8a9fe49aadb5c1d67de48d9232363963.zip
Initial commit
Diffstat (limited to 'client/src/main.cpp')
-rw-r--r--client/src/main.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/src/main.cpp b/client/src/main.cpp
new file mode 100644
index 0000000..1dc9db2
--- /dev/null
+++ b/client/src/main.cpp
@@ -0,0 +1,29 @@
+#include "include.h"
+#include "util/io.h"
+#include "client/client.h"
+
+int main(int argc, char *argv[]) {
+ tcp::client client;
+ if (client.start("127.0.0.1", 6666)) {
+ io::logger->info("connected.");
+ client.set_state(tcp::client_state::active);
+ }
+
+ client.on_recv().add([&](std::string msg) {
+ io::logger->info(msg);
+ });
+
+ std::thread t{tcp::client::read, std::ref(client)};
+
+ while (client.is_active()) {
+ std::string p;
+ getline(std::cin, p);
+
+ bool ret = client.send_message(p);
+ if (!ret) {
+ break;
+ }
+ }
+
+ t.join();
+}