Added send with callback.
This commit is contained in:
parent
3752551e53
commit
83a5923568
9 changed files with 127 additions and 72 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/stratum/BaseClient.h"
|
||||
#include "base/net/stratum/SubmitResult.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -42,6 +43,32 @@ xmrig::BaseClient::BaseClient(int id, IClientListener *listener) :
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::BaseClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||
{
|
||||
if (id == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = m_callbacks.find(id);
|
||||
if (it != m_callbacks.end()) {
|
||||
const uint64_t elapsed = Chrono::steadyMSecs() - it->second.ts;
|
||||
|
||||
if (error.IsObject()) {
|
||||
it->second.callback(error, false, elapsed);
|
||||
}
|
||||
else {
|
||||
it->second.callback(result, true, elapsed);
|
||||
}
|
||||
|
||||
m_callbacks.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::BaseClient::handleSubmitResponse(int64_t id, const char *error)
|
||||
{
|
||||
auto it = m_results.find(id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue