From 2e3f1b0f9ba9f0f438b3ecb82f6478227eb2ac8b Mon Sep 17 00:00:00 2001 From: Almog Hamdani Date: Thu, 24 Oct 2019 20:26:37 +0300 Subject: [PATCH] refactor(client): change disconnected handler to logged out event --- client/backend/src/core/auth.cpp | 6 +++--- client/backend/src/core/auth.h | 2 +- client/backend/src/core/client.cpp | 20 ++++++++++---------- client/backend/src/core/client.h | 2 +- client/backend/src/core/files.cpp | 2 +- client/backend/src/core/files.h | 2 +- client/backend/src/core/module.h | 2 +- client/backend/src/core/voice.cpp | 2 +- client/backend/src/core/voice.h | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/client/backend/src/core/auth.cpp b/client/backend/src/core/auth.cpp index aa5bd78..35f6790 100644 --- a/client/backend/src/core/auth.cpp +++ b/client/backend/src/core/auth.cpp @@ -92,15 +92,15 @@ void quesync::client::modules::auth::logout() { // Send the logout packet to the server _client->communicator()->send_and_verify(&logout_packet, packet_type::logged_out_packet); - // Send the disconnected event to the modules - _client->disconnected(); + // Send the logged out event to the modules + _client->logged_out(); } std::shared_ptr quesync::client::modules::auth::get_user() { return _user; } std::string quesync::client::modules::auth::get_session_id() { return _session_id; } -void quesync::client::modules::auth::disconnected() { +void quesync::client::modules::auth::logged_out() { _user = nullptr; _session_id = ""; } \ No newline at end of file diff --git a/client/backend/src/core/auth.h b/client/backend/src/core/auth.h index 1c21922..34b73de 100644 --- a/client/backend/src/core/auth.h +++ b/client/backend/src/core/auth.h @@ -21,7 +21,7 @@ class auth : public module { std::shared_ptr get_user(); std::string get_session_id(); - virtual void disconnected(); + virtual void logged_out(); private: std::shared_ptr _user; diff --git a/client/backend/src/core/client.cpp b/client/backend/src/core/client.cpp index 087d646..37f6de5 100644 --- a/client/backend/src/core/client.cpp +++ b/client/backend/src/core/client.cpp @@ -48,7 +48,7 @@ void quesync::client::client::clean_connection() { // If the user is authenticated, disconnect it if (_auth->get_user()) { - disconnected(); + logged_out(); } // Clean modules @@ -69,15 +69,15 @@ void quesync::client::client::clean_connection() { } } -void quesync::client::client::disconnected() { - // Send disconnected event to modules - _auth->disconnected(); - _users->disconnected(); - _messages->disconnected(); - _channels->disconnected(); - _voice->disconnected(); - _files->disconnected(); - _user->disconnected(); +void quesync::client::client::logged_out() { + // Send logged out event to modules + _auth->logged_out(); + _users->logged_out(); + _messages->logged_out(); + _channels->logged_out(); + _voice->logged_out(); + _files->logged_out(); + _user->logged_out(); } std::shared_ptr quesync::client::client::communicator() { diff --git a/client/backend/src/core/client.h b/client/backend/src/core/client.h index b81bd61..b3b111b 100644 --- a/client/backend/src/core/client.h +++ b/client/backend/src/core/client.h @@ -32,7 +32,7 @@ class client : public std::enable_shared_from_this { std::shared_ptr user(); void clean_connection(); - void disconnected(); + void logged_out(); private: std::shared_ptr _communicator; diff --git a/client/backend/src/core/files.cpp b/client/backend/src/core/files.cpp index 66f4470..850c958 100644 --- a/client/backend/src/core/files.cpp +++ b/client/backend/src/core/files.cpp @@ -514,4 +514,4 @@ void quesync::client::modules::files::clean_connection(bool join_com_thread) { _events.clear(); } -void quesync::client::modules::files::disconnected() { clean_connection(); } \ No newline at end of file +void quesync::client::modules::files::logged_out() { clean_connection(); } \ No newline at end of file diff --git a/client/backend/src/core/files.h b/client/backend/src/core/files.h index 04c58ec..52a002a 100644 --- a/client/backend/src/core/files.h +++ b/client/backend/src/core/files.h @@ -34,7 +34,7 @@ class files : public module { std::shared_ptr get_file_info(std::string file_id); virtual void clean_connection(bool join_com_thread=true); - virtual void disconnected(); + virtual void logged_out(); private: std::mutex _send_mutex; diff --git a/client/backend/src/core/module.h b/client/backend/src/core/module.h index 2f08c45..a07bc4f 100644 --- a/client/backend/src/core/module.h +++ b/client/backend/src/core/module.h @@ -12,7 +12,7 @@ class module { module(std::shared_ptr client) : _client(client) {} virtual void clean_connection() {} - virtual void disconnected() {} + virtual void logged_out() {} virtual void connected(std::string server_ip) {} protected: diff --git a/client/backend/src/core/voice.cpp b/client/backend/src/core/voice.cpp index 55aac58..87d0616 100644 --- a/client/backend/src/core/voice.cpp +++ b/client/backend/src/core/voice.cpp @@ -170,7 +170,7 @@ void quesync::client::modules::voice::clean_connection() { } } -void quesync::client::modules::voice::disconnected() { +void quesync::client::modules::voice::logged_out() { // Disable the voice and reset it's state if enabled if (_voice_manager) { _voice_manager->disable(); diff --git a/client/backend/src/core/voice.h b/client/backend/src/core/voice.h index 983faeb..9a47f7e 100644 --- a/client/backend/src/core/voice.h +++ b/client/backend/src/core/voice.h @@ -25,7 +25,7 @@ class voice : public module { void leave_call(); virtual void clean_connection(); - virtual void disconnected(); + virtual void logged_out(); virtual void connected(std::string server_ip); private: