mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/DBLayer: Convert async queries to new query callbacks and remove old callback handling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user