mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
server player req: parse malformed json
ATM10 server seems to send a extra json object after the default response, that we need to cut off. Signed-off-by: Tayou <git@tayou.org> Co-authored-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
8cfed54399
commit
5ebd386797
2 changed files with 19 additions and 2 deletions
|
|
@ -1,13 +1,19 @@
|
|||
#include <QFutureWatcher>
|
||||
|
||||
#include <Json.h>
|
||||
#include "Exception.h"
|
||||
#include "McClient.h"
|
||||
#include "McResolver.h"
|
||||
#include "ServerPingTask.h"
|
||||
|
||||
unsigned getOnlinePlayers(QJsonObject data)
|
||||
{
|
||||
return Json::requireInteger(Json::requireObject(data, "players"), "online");
|
||||
try {
|
||||
return Json::requireInteger(Json::requireObject(data, "players"), "online");
|
||||
} catch (Exception& e) {
|
||||
qWarning() << "server ping failed to parse response" << e.what();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ServerPingTask::executeTask()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue