-
Notifications
You must be signed in to change notification settings - Fork 68
Add reconnect button to disconnection notice. #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reads and begins the connection process to the last server the user disconnected from. Doesn't complete the connection process.. yet.
src/debug_functions.h
Outdated
class debug_functions : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit debug_functions(AOApplication *parent); | ||
AOApplication *ao_app; | ||
|
||
void call_notice_reconnect(QString message); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning behind making this an object over a simple function call? I don't see a reason as to why it would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was made into an object because I needed to pass the parent / ao_app into the function of call_notice_reconnect. Couldn't find a way of doing that without extending the QObject from a class.
Do you know an example implementation for doing it without having to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply add a bool prompt_choice(QString message)
which either allow you to accept or cancel. That way you keep it within a singular function and can use it elsewhere within the code. Additionally, the return value will make it easy on whatever reconnecting is wanted by the user or not.
// if (is_lobby_constructed()) | ||
// {} | ||
// l_dialog->exec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remove these, this snippet is for the execution of the lobby settings when the settings button is pressed.
Currently, pressing it causes a disconnection for the purposes of testing the reconnection button.
src/aoapplication.cpp
Outdated
call_notice(tr("Disconnected from server.")); | ||
construct_lobby(); | ||
destruct_courtroom(); | ||
// call_notice(tr("Disconnected from server.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove rather than comment out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/aoapplication.cpp
Outdated
: QObject(parent) | ||
{ | ||
net_manager = new NetworkManager(this); | ||
debug_func = new debug_functions(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug_func
is too vague as a variable name.
debug_functions
is meaningless as a class name nor does it follow at all any kind of somewhat established naming convention.
src/debug_functions.cpp
Outdated
|
||
void debug_functions::call_notice_reconnect(QString p_message) | ||
{ | ||
auto *msgBox = new QMessageBox; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a member variable.
src/debug_functions.cpp
Outdated
QTimer intervalTimer; | ||
intervalTimer.setInterval(1000); | ||
|
||
int counter = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a member variable.
src/debug_functions.h
Outdated
class debug_functions : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit debug_functions(AOApplication *parent); | ||
AOApplication *ao_app; | ||
|
||
void call_notice_reconnect(QString message); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply add a bool prompt_choice(QString message)
which either allow you to accept or cancel. That way you keep it within a singular function and can use it elsewhere within the code. Additionally, the return value will make it easy on whatever reconnecting is wanted by the user or not.
…ead. Co-Authored-By: Leifa <[email protected]>
Reconnects to last server fully. Sends to character select screen.
class Lobby; | ||
class Courtroom; | ||
class Options; | ||
class debug_functions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs removed
|
||
void NetworkManager::reconnect_to_last_server() | ||
{ | ||
connect(this, &NetworkManager::server_connected, this, &NetworkManager::join_to_server); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs disconnected after rejoining the server.
Reads and begins the connection process to the last server the user disconnected from. Doesn't complete the connection process.