NETWORKING: Changed PostRequest to accept JSONValue

This commit is contained in:
Eugene Sandulenko 2019-10-24 00:02:54 +02:00
parent 0ad210a5a4
commit a0c58a53b3
3 changed files with 5 additions and 4 deletions

View file

@ -31,6 +31,7 @@ namespace Networking {
typedef Response<Common::JSONValue *> JsonResponse; typedef Response<Common::JSONValue *> JsonResponse;
typedef Common::BaseCallback<JsonResponse> *JsonCallback; typedef Common::BaseCallback<JsonResponse> *JsonCallback;
typedef Common::BaseCallback<Common::JSONValue *> *JSONValueCallback;
#define CURL_JSON_REQUEST_BUFFER_SIZE 512 * 1024 #define CURL_JSON_REQUEST_BUFFER_SIZE 512 * 1024

View file

@ -28,7 +28,7 @@
namespace Networking { namespace Networking {
PostRequest::PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb): PostRequest::PostRequest(Common::String url, byte *postData, int postLen, Networking::JSONValueCallback cb, Networking::ErrorCallback ecb):
Networking::Request(nullptr, ecb), _url(url), _jsonCallback(cb), Networking::Request(nullptr, ecb), _url(url), _jsonCallback(cb),
_workingRequest(nullptr), _ignoreCallback(false), _postData(postData), _postLen(postLen) { _workingRequest(nullptr), _ignoreCallback(false), _postData(postData), _postLen(postLen) {
start(); start();
@ -87,7 +87,7 @@ void PostRequest::responseCallback(Networking::JsonResponse response) {
finishSuccess(); finishSuccess();
if (_jsonCallback) if (_jsonCallback)
(*_jsonCallback)(Networking::JsonResponse(this, json)); (*_jsonCallback)(json);
delete json; delete json;
} }

View file

@ -30,7 +30,7 @@ namespace Networking {
class PostRequest: public Networking::Request { class PostRequest: public Networking::Request {
Common::String _url; Common::String _url;
Networking::JsonCallback _jsonCallback; Networking::JSONValueCallback _jsonCallback;
Request *_workingRequest; Request *_workingRequest;
bool _ignoreCallback; bool _ignoreCallback;
Common::String _date; Common::String _date;
@ -43,7 +43,7 @@ class PostRequest: public Networking::Request {
void errorCallback(Networking::ErrorResponse error); void errorCallback(Networking::ErrorResponse error);
public: public:
PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb); PostRequest(Common::String url, byte *postData, int postLen, Networking::JSONValueCallback cb, Networking::ErrorCallback ecb);
virtual ~PostRequest(); virtual ~PostRequest();
virtual void handle(); virtual void handle();