-
-
Notifications
You must be signed in to change notification settings - Fork 676
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
Show online players on servers screen #3112
base: develop
Are you sure you want to change the base?
Conversation
Ok, all conversations have been resolved, and the feature feels complete to me. I think this PR can be considered for merging |
I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: fac521a I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 43a54ca I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: ee35ac5 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 99ac11b I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 8fa1dff I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 2f70115 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: ea2a234 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 87c9066 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: fe28a05 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 0a379a0 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 6a7678a I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: cba7e2d I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 8cf0c20 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 0d830e5 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: b35cffb I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 1f094b9 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 2d06e0a I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: c3543b1 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 8b7040d I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: b8035ca I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 9d5727e I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 7cf2458 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 7d04f0e I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 60fb922 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: a79a66c I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 1fb0fe0 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 5cfb5a6 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 9ce5eaa I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 0c6f78d I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 7c8d2c9 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 24b9815 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 7d2da19 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: ca6d669 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 520d6b0 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 4fad298 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 087ab70 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 7c61fec I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: fef8ee2 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 3a9c030 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: f05548f I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 66f3619 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: ca52d00 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 26f50f9 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 873232e I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 8b90a9f I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: dbb88ca I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 6f9be25 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: d124e2e I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: cfb0c97 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 5eb417f I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 3fb6764 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: ae7d337 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 0978274 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: b0778e7 I, iTrooz <hey@itrooz.fr>, hereby add my Signed-off-by to this commit: 01db826 Signed-off-by: iTrooz <hey@itrooz.fr>
Signed-off-by: iTrooz <hey@itrooz.fr>
Signed-off-by: iTrooz <hey@itrooz.fr>
Signed-off-by: iTrooz <hey@itrooz.fr>
Signed-off-by: iTrooz <hey@itrooz.fr>
return QtConcurrent::run([this]() { | ||
try { | ||
auto status = getStatusDataBlocking(); | ||
auto players = Json::requireObject(status, "players"); | ||
return Json::requireInteger(players, "online"); | ||
} catch (const Exception &e) { | ||
qDebug() << "Error: " << e.what(); | ||
return -1; | ||
} | ||
}); |
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 feels a bit pointless to use a thread when it is just waiting doing nothing while another thread does the actual work...
Also, this method is not recommended on Windows
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.
hey ! Sorry for the long delay
It feels a bit pointless to use a thread when it is just waiting doing nothing while another thread does the actual work...
In this case the main thread is not really waiting, since QtConcurrent::run()
returns a future, that is later "awaited" here:
QObject::connect(watcher, &QFutureWatcher<int>::finished, this, [this, client, onlineFuture, watcher]() { |
If you want, I can try to handle the socket IO operations from the main GUI thread, but it didn't seem like a good option to me (shouldn't the main thread only do GUI stuff ?)
Also, this method is not recommended on Windows
I do not have much experience with Windows, could you clarify what is the bad pattern here ?
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'm with iTrooz here:
- it is bad to do this in the UI thread
- we already use a similar pattern when extracting files
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.
Pretty sure all the waitFor methods do is make the thread sleep until the work is done. The rest of the work the thread does is just light parsing
I do not have much experience with Windows, could you clarify what is the bad pattern here ?
https://doc.qt.io/qt-6/qabstractsocket.html#waitForConnected
Note: This function may fail randomly on Windows. Consider using the event loop and the connected() signal if your software will run on Windows.
No description provided.