aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver/Server/AuthSession.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-01-13 21:38:03 +0100
committerariel- <ariel-@users.noreply.github.com>2017-01-25 23:38:13 -0300
commit4c27203c8f36dd2a5df0a4ae69fbdc4c9140b29d (patch)
tree175c45945668243f86642b40cfadac92823f6c9f /src/server/authserver/Server/AuthSession.cpp
parent8af3cccc83aa7fbda348a784e36f45331c091c9a (diff)
Core/DBLayer: Convert async queries to new query callbacks and remove old callback handling
(cherry picked from commit 8e2634b2b49eb814b8cc425a060b2f160dbb49b7) Conflicts: src/server/bnetserver/Server/Session.cpp src/server/bnetserver/Server/Session.h src/server/database/Database/QueryCallback.cpp src/server/game/Handlers/CharacterHandler.cpp src/server/game/Handlers/SocialHandler.cpp src/server/game/Server/WorldSession.cpp src/server/game/Server/WorldSession.h src/server/game/Server/WorldSocket.cpp src/server/game/Server/WorldSocket.h src/server/game/World/World.cpp src/server/game/World/World.h
Diffstat (limited to 'src/server/authserver/Server/AuthSession.cpp')
-rw-r--r--src/server/authserver/Server/AuthSession.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index 0dbf7841e07..5c3ed477ace 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -169,8 +169,7 @@ void AuthSession::Start()
stmt->setString(0, ip_address);
stmt->setUInt32(1, inet_addr(ip_address.c_str()));
- _queryCallback = std::bind(&AuthSession::CheckIpCallback, this, std::placeholders::_1);
- _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ _queryCallback = std::move(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::CheckIpCallback, this, std::placeholders::_1)));
}
bool AuthSession::Update()
@@ -178,12 +177,8 @@ bool AuthSession::Update()
if (!AuthSocket::Update())
return false;
- if (_queryFuture.valid() && _queryFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
- {
- auto callback = _queryCallback;
- _queryCallback = nullptr;
- callback(_queryFuture.get());
- }
+ if (_queryCallback && _queryCallback->InvokeIfReady() == QueryCallback::Completed)
+ _queryCallback = boost::none;
return true;
}
@@ -323,8 +318,7 @@ bool AuthSession::HandleLogonChallenge()
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGONCHALLENGE);
stmt->setString(0, login);
- _queryCallback = std::bind(&AuthSession::LogonChallengeCallback, this, std::placeholders::_1);
- _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ _queryCallback = std::move(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::LogonChallengeCallback, this, std::placeholders::_1)));
return true;
}
@@ -737,8 +731,7 @@ bool AuthSession::HandleReconnectChallenge()
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RECONNECTCHALLENGE);
stmt->setString(0, login);
- _queryCallback = std::bind(&AuthSession::ReconnectChallengeCallback, this, std::placeholders::_1);
- _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ _queryCallback = std::move(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::ReconnectChallengeCallback, this, std::placeholders::_1)));
return true;
}
@@ -819,8 +812,7 @@ bool AuthSession::HandleRealmList()
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_REALM_CHARACTER_COUNTS);
stmt->setUInt32(0, _accountInfo.Id);
- _queryCallback = std::bind(&AuthSession::RealmListCallback, this, std::placeholders::_1);
- _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ _queryCallback = std::move(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::RealmListCallback, this, std::placeholders::_1)));
return true;
}