diff options
Diffstat (limited to 'client/src/main.cpp')
| -rw-r--r-- | client/src/main.cpp | 29 |
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(); +} |