aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Server/SessionManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/bnetserver/Server/SessionManager.cpp')
-rw-r--r--src/server/bnetserver/Server/SessionManager.cpp39
1 files changed, 3 insertions, 36 deletions
diff --git a/src/server/bnetserver/Server/SessionManager.cpp b/src/server/bnetserver/Server/SessionManager.cpp
index ed36a3630e1..1920496ffff 100644
--- a/src/server/bnetserver/Server/SessionManager.cpp
+++ b/src/server/bnetserver/Server/SessionManager.cpp
@@ -37,41 +37,8 @@ void Battlenet::SessionManager::OnSocketAccept(tcp::socket&& sock, uint32 thread
sSessionMgr.OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
}
-void Battlenet::SessionManager::AddSession(Session* session)
+Battlenet::SessionManager& Battlenet::SessionManager::Instance()
{
- std::unique_lock<boost::shared_mutex> lock(_sessionMutex);
- _sessions[{ session->GetAccountId(), session->GetGameAccountId() }] = session;
- _sessionsByAccountId[session->GetAccountId()].push_back(session);
-}
-
-void Battlenet::SessionManager::RemoveSession(Session* session)
-{
- std::unique_lock<boost::shared_mutex> lock(_sessionMutex);
- auto itr = _sessions.find({ session->GetAccountId(), session->GetGameAccountId() });
- // Remove old session only if it was not overwritten by reconnecting
- if (itr != _sessions.end() && itr->second == session)
- _sessions.erase(itr);
-
- _sessionsByAccountId[session->GetAccountId()].remove(session);
-}
-
-Battlenet::Session* Battlenet::SessionManager::GetSession(uint32 accountId, uint32 gameAccountId) const
-{
- boost::shared_lock<boost::shared_mutex> lock(_sessionMutex);
- auto itr = _sessions.find({ accountId, gameAccountId });
- if (itr != _sessions.end())
- return itr->second;
-
- return nullptr;
-}
-
-std::list<Battlenet::Session*> Battlenet::SessionManager::GetSessions(uint32 accountId) const
-{
- boost::shared_lock<boost::shared_mutex> lock(_sessionMutex);
- std::list<Session*> sessions;
- auto itr = _sessionsByAccountId.find(accountId);
- if (itr != _sessionsByAccountId.end())
- sessions = itr->second;
-
- return sessions;
+ static SessionManager instance;
+ return instance;
}