MCPcopy Create free account
hub / github.com/PlayFab/gsdk / CurlReceiveData

Method CurlReceiveData

cpp/cppsdk/source/playfab/PlayFabHttp.cpp:113–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 size_t PlayFabHttp::CurlReceiveData(char* buffer, size_t blockSize, size_t blockCount, void* userData)
114 {
115 CallRequestContainer* reqContainer = reinterpret_cast<CallRequestContainer*>(userData);
116 reqContainer->responseString.assign(buffer, blockSize * blockCount);
117
118 Json::CharReaderBuilder jsonReaderFactory;
119 Json::CharReader* jsonReader(jsonReaderFactory.newCharReader());
120 JSONCPP_STRING jsonParseErrors;
121 const bool parsedSuccessfully = jsonReader->parse(reqContainer->responseString.c_str(), reqContainer->responseString.c_str() + reqContainer->responseString.length(), &reqContainer->responseJson, &jsonParseErrors);
122
123 if (parsedSuccessfully)
124 {
125 reqContainer->errorWrapper.HttpCode = reqContainer->responseJson.get("code", Json::Value::null).asInt();
126 reqContainer->errorWrapper.HttpStatus = reqContainer->responseJson.get("status", Json::Value::null).asString();
127 reqContainer->errorWrapper.Data = reqContainer->responseJson.get("data", Json::Value::null);
128 reqContainer->errorWrapper.ErrorName = reqContainer->responseJson.get("error", Json::Value::null).asString();
129 reqContainer->errorWrapper.ErrorMessage = reqContainer->responseJson.get("errorMessage", Json::Value::null).asString();
130 reqContainer->errorWrapper.ErrorDetails = reqContainer->responseJson.get("errorDetails", Json::Value::null);
131 }
132 else
133 {
134 reqContainer->errorWrapper.HttpCode = 408;
135 reqContainer->errorWrapper.HttpStatus = reqContainer->responseString;
136 reqContainer->errorWrapper.ErrorCode = PlayFabErrorConnectionTimeout;
137 reqContainer->errorWrapper.ErrorName = "Failed to parse PlayFab response";
138 reqContainer->errorWrapper.ErrorMessage = jsonParseErrors;
139 }
140
141 HandleCallback(*reqContainer);
142 return (blockSize * blockCount);
143 }
144
145 void PlayFabHttp::AddRequest(const std::string& urlPath, const std::string& authKey, const std::string& authValue, const Json::Value& requestBody, RequestCompleteCallback internalCallback, SharedVoidPointer successCallback, ErrorCallback errorCallback, void* customData)
146 {

Callers

nothing calls this directly

Calls 6

newCharReaderMethod · 0.80
lengthMethod · 0.80
asIntMethod · 0.80
getMethod · 0.80
asStringMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected