You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
910 B
25 lines
910 B
#include "XHttpClientCallback.h"
|
|
#include "HttpClient.h"
|
|
#include "XGlobal.h"
|
|
|
|
XHttpClientCallback::XHttpClientCallback(HttpClient* client)
|
|
: client(client)
|
|
{
|
|
connect(client, &HttpClient::finished, this, &XHttpClientCallback::finished, Qt::QueuedConnection);
|
|
connect(client, &HttpClient::error, this, &XHttpClientCallback::error, Qt::QueuedConnection);
|
|
}
|
|
|
|
void XHttpClientCallback::setInfo(const char* id, const char* method) {
|
|
reqId = QString(id);
|
|
reqMethod = QString(method);
|
|
}
|
|
|
|
void XHttpClientCallback::finished(const QJsonDocument& json) {
|
|
XGlobal::getInstance().onHttpRequest(reqId.toStdString().c_str(), reqMethod.toStdString().c_str(), true, json.toJson().constData());
|
|
client->setFinished();
|
|
}
|
|
|
|
void XHttpClientCallback::error(const QString& errTxt) {
|
|
XGlobal::getInstance().onHttpRequest(reqId.toStdString().c_str(), reqMethod.toStdString().c_str(), false, nullptr);
|
|
client->setFinished();
|
|
} |