Skip to content

Conversation

WisoAltred
Copy link

Reads and begins the connection process to the last server the user disconnected from. Doesn't complete the connection process.

Reads and begins the connection process to the last server the user disconnected from. Doesn't complete the connection process.. yet.
@Salanto Salanto marked this pull request as draft May 27, 2025 16:02
Comment on lines 10 to 19
class debug_functions : public QObject
{
Q_OBJECT

public:
explicit debug_functions(AOApplication *parent);
AOApplication *ao_app;

void call_notice_reconnect(QString message);
};
Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

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.

Comment on lines +172 to +174
// if (is_lobby_constructed())
// {}
// l_dialog->exec();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

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.

call_notice(tr("Disconnected from server."));
construct_lobby();
destruct_courtroom();
// call_notice(tr("Disconnected from server."));
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

: QObject(parent)
{
net_manager = new NetworkManager(this);
debug_func = new debug_functions(this);
Copy link
Contributor

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.


void debug_functions::call_notice_reconnect(QString p_message)
{
auto *msgBox = new QMessageBox;
Copy link
Contributor

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.

QTimer intervalTimer;
intervalTimer.setInterval(1000);

int counter = 3;
Copy link
Contributor

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.

Comment on lines 10 to 19
class debug_functions : public QObject
{
Q_OBJECT

public:
explicit debug_functions(AOApplication *parent);
AOApplication *ao_app;

void call_notice_reconnect(QString message);
};
Copy link
Contributor

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.

class Lobby;
class Courtroom;
class Options;
class debug_functions;
Copy link
Contributor

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);
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants