aboutsummaryrefslogtreecommitdiff
path: root/client/src/main.cpp
diff options
context:
space:
mode:
authoralpine <[email protected]>2020-06-18 22:19:30 +0200
committeralpine <[email protected]>2020-06-18 22:19:30 +0200
commitc880bb35ac9b0744be38a66b6e8860464fe304ed (patch)
treee81ebc8fd5dc9614534bafaeb9e39a089738a94d /client/src/main.cpp
parentFinished session id on client and server. (diff)
downloadloader-c880bb35ac9b0744be38a66b6e8860464fe304ed.tar.xz
loader-c880bb35ac9b0744be38a66b6e8860464fe304ed.zip
Changed clang format style.
Diffstat (limited to 'client/src/main.cpp')
-rw-r--r--client/src/main.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/client/src/main.cpp b/client/src/main.cpp
index 48a4e19..3cc3c77 100644
--- a/client/src/main.cpp
+++ b/client/src/main.cpp
@@ -2,39 +2,40 @@
#include "util/io.h"
#include "client/client.h"
-int main(int argc, char *argv[]) {
- io::init();
+int main(int argc, char* argv[])
+{
+ io::init();
- tcp::client client;
+ tcp::client client;
- std::thread t{tcp::client::monitor, std::ref(client)};
- t.detach();
+ std::thread t{ tcp::client::monitor, std::ref(client) };
+ t.detach();
- if (client.start("127.0.0.1", 6666)) {
- io::logger->info("connected.");
- client.set_state(tcp::client_state::active);
- }
+ if(client.start("127.0.0.1", 6666)) {
+ io::logger->info("connected.");
+ client.set_state(tcp::client_state::active);
+ }
- client.receive_event.add([&](tcp::packet_t &packet) {
- if (!packet) return;
+ client.receive_event.add([&](tcp::packet_t& packet) {
+ if(!packet)
+ return;
- // first packet is the session id and current version
- if (packet.id == 1) {
- client.session_id = packet.session_id;
-
- }
+ // first packet is the session id and current version
+ if(packet.id == 1) {
+ client.session_id = packet.session_id;
+ }
- io::logger->info("{}:{}->{}", packet.id, packet.session_id, packet.message);
- });
+ io::logger->info("{}:{}->{}", packet.id, packet.session_id, packet.message);
+ });
- while (client) {
- std::string p;
- getline(std::cin, p);
+ while(client) {
+ std::string p;
+ getline(std::cin, p);
- int ret = client.write(
- tcp::packet_t(p, tcp::packet_type::write, client.session_id));
- if (ret <= 0) {
- break;
+ int ret =
+ client.write(tcp::packet_t(p, tcp::packet_type::write, client.session_id));
+ if(ret <= 0) {
+ break;
+ }
}
- }
}