Core/DBLayer: Convert async queries to new query callbacks and remove old callback handling

This commit is contained in:
Shauren
2017-01-13 21:38:03 +01:00
parent 0f432edc4b
commit 8e2634b2b4
19 changed files with 391 additions and 755 deletions

View File

@@ -19,6 +19,7 @@
#include "BattlenetRpcErrorCodes.h"
#include "ByteConverter.h"
#include "Database/DatabaseEnv.h"
#include "QueryCallback.h"
#include "LoginRESTService.h"
#include "ProtobufJSON.h"
#include "RealmList.h"
@@ -91,8 +92,7 @@ void Battlenet::Session::Start()
stmt->setString(0, ip_address);
stmt->setUInt32(1, inet_addr(ip_address.c_str()));
_queryCallback = std::bind(&Battlenet::Session::CheckIpCallback, this, std::placeholders::_1);
_queryFuture = LoginDatabase.AsyncQuery(stmt);
_queryProcessor.AddQuery(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&Battlenet::Session::CheckIpCallback, this, std::placeholders::_1)));
}
void Battlenet::Session::CheckIpCallback(PreparedQueryResult result)
@@ -127,12 +127,7 @@ bool Battlenet::Session::Update()
if (!BattlenetSocket::Update())
return false;
if (_queryFuture.valid() && _queryFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
{
auto callback = std::move(_queryCallback);
_queryCallback = nullptr;
callback(_queryFuture.get());
}
_queryProcessor.ProcessReadyQueries();
return true;
}