-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Resurrect ServerAgent for external tool access #6044
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,12 @@ | |
#pragma comment(lib, "libcurl.lib") | ||
#endif | ||
|
||
#include "buildopts.h" | ||
#include "ServerAgent.h" | ||
#include "StringF.h" | ||
#include <curl/curl.h> | ||
#include <SDL.h> | ||
#include <SDL_Thread.h> | ||
|
||
void NullServerAgent::Call(const std::string &method, const Json &data, SuccessCallback onSuccess, FailCallback onFail, void *userdata) | ||
{ | ||
|
@@ -153,8 +156,7 @@ void HTTPServerAgent::ThreadMain() | |
// done with the queue | ||
SDL_UnlockMutex(m_requestQueueLock); | ||
|
||
Json::FastWriter writer; | ||
req.buffer = writer.write(req.data); | ||
req.buffer = req.data; | ||
|
||
Response resp(req.onSuccess, req.onFail, req.userdata); | ||
|
||
|
@@ -178,10 +180,10 @@ void HTTPServerAgent::ThreadMain() | |
} | ||
|
||
if (resp.success) { | ||
Json::Reader reader; | ||
resp.success = reader.parse(resp.buffer, resp.data, false); | ||
if (!resp.success) | ||
resp.buffer = std::string("JSON parse error: " + reader.getFormattedErrorMessages()); | ||
//Json::Reader reader; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sturnclaw second is this section which I think deserialised a response There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll likely also need to wrap it in a try block or use a non-throwing method; still getting my development environment back up so that's an exercise left to the reader. |
||
//resp.success = reader.parse(resp.buffer, resp.data, false); | ||
//if (!resp.success) | ||
// resp.buffer = std::string("JSON parse error: " + reader.getFormattedErrorMessages()); | ||
} | ||
|
||
SDL_LockMutex(m_responseQueueLock); | ||
|
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.
@sturnclaw this is one of the two problems I could do with some advice about, this line is not an equivalent replacement for the
writer.write(req.data)
which used to be there which I believe serialised the data.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.
You want
req.buffer = req.data.dump()
; the arguments to the dump function are the amount of indentation and the indent character, neither of which should be used for over-the-wire serialization.