Skip to content

Commit

Permalink
refactor(client): change disconnected handler to logged out event
Browse files Browse the repository at this point in the history
  • Loading branch information
almoghamdani committed Oct 24, 2019
1 parent 56cf6f1 commit 2e3f1b0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions client/backend/src/core/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::user> 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 = "";
}
2 changes: 1 addition & 1 deletion client/backend/src/core/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class auth : public module {
std::shared_ptr<quesync::user> get_user();
std::string get_session_id();

virtual void disconnected();
virtual void logged_out();

private:
std::shared_ptr<quesync::user> _user;
Expand Down
20 changes: 10 additions & 10 deletions client/backend/src/core/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::modules::communicator> quesync::client::client::communicator() {
Expand Down
2 changes: 1 addition & 1 deletion client/backend/src/core/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class client : public std::enable_shared_from_this<client> {
std::shared_ptr<modules::user> user();

void clean_connection();
void disconnected();
void logged_out();

private:
std::shared_ptr<modules::communicator> _communicator;
Expand Down
2 changes: 1 addition & 1 deletion client/backend/src/core/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
void quesync::client::modules::files::logged_out() { clean_connection(); }
2 changes: 1 addition & 1 deletion client/backend/src/core/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class files : public module {
std::shared_ptr<file> 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;
Expand Down
2 changes: 1 addition & 1 deletion client/backend/src/core/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class module {
module(std::shared_ptr<client> client) : _client(client) {}

virtual void clean_connection() {}
virtual void disconnected() {}
virtual void logged_out() {}
virtual void connected(std::string server_ip) {}

protected:
Expand Down
2 changes: 1 addition & 1 deletion client/backend/src/core/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion client/backend/src/core/voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2e3f1b0

Please sign in to comment.