diff options
| author | alpine <[email protected]> | 2020-06-15 22:15:02 +0200 |
|---|---|---|
| committer | alpine <[email protected]> | 2020-06-15 22:15:02 +0200 |
| commit | ede39016d04b661c7102d8d26c800acb08aa629c (patch) | |
| tree | 85f82718ab91934f57d15a6860ebdec6cf46be54 /client/src | |
| parent | Removed xor as it was slowing down everything alot. (diff) | |
| download | loader-ede39016d04b661c7102d8d26c800acb08aa629c.tar.xz loader-ede39016d04b661c7102d8d26c800acb08aa629c.zip | |
Finished session/user id generation.
Diffstat (limited to 'client/src')
| -rw-r--r-- | client/src/client/client.cpp | 8 | ||||
| -rw-r--r-- | client/src/client/client.h | 10 | ||||
| -rw-r--r-- | client/src/main.cpp | 6 |
3 files changed, 18 insertions, 6 deletions
diff --git a/client/src/client/client.cpp b/client/src/client/client.cpp index e224a95..9688543 100644 --- a/client/src/client/client.cpp +++ b/client/src/client/client.cpp @@ -39,6 +39,14 @@ bool tcp::client::start(const std::string_view server_ip, const uint16_t port) { return true; } +bool tcp::client::set_uid() { + m_uid.resize(tcp::uid_len); + + int ret = read(&m_uid[0], tcp::uid_len); + if(ret != tcp::uid_len) return false; + return true; +} + int tcp::client::read_stream(std::vector<char> &out) { size_t size; read(&size, sizeof(size)); diff --git a/client/src/client/client.h b/client/src/client/client.h index 34e761b..992cae6 100644 --- a/client/src/client/client.h +++ b/client/src/client/client.h @@ -5,11 +5,7 @@ namespace tcp { -enum client_state : uint8_t { - idle = 0, - active, - standby -}; +enum client_state : uint8_t { idle = 0, active, standby }; class client { int m_socket; @@ -18,6 +14,7 @@ class client { SSL *m_server_ssl; SSL_CTX *m_ssl_ctx; + std::string m_uid; public: event<packet_t &> receive_event; @@ -34,9 +31,10 @@ class client { } int read_stream(std::vector<char> &out); - int stream(std::vector<char> &data); + bool set_uid(); + int get_socket() { return m_socket; } bool is_active() { return m_state == client_state::active; } void set_state(const uint8_t &state) { m_state = state; } diff --git a/client/src/main.cpp b/client/src/main.cpp index c94a866..a9fecec 100644 --- a/client/src/main.cpp +++ b/client/src/main.cpp @@ -8,6 +8,11 @@ int main(int argc, char *argv[]) { tcp::client client; if (client.start("127.0.0.1", 6666)) { + if(!client.set_uid()) { + io::logger->error("failed to set session id."); + return 0; + } + io::logger->info("connected."); client.set_state(tcp::client_state::active); } @@ -16,6 +21,7 @@ int main(int argc, char *argv[]) { if(!packet) return; + io::logger->info(packet.message); if(packet.message == "stream") { std::vector<char> dat; client.read_stream(dat); |