From 4aa991e7e4450232df4ceda0b2f439bccce1d260 Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 8 Apr 2025 19:15:16 +0200 Subject: Core/Network: Socket refactors * Devirtualize calls to Read and Update by marking concrete implementations as final * Removed derived class template argument * Specialize boost::asio::basic_stream_socket for boost::asio::io_context instead of type-erased any_io_executor * Make socket initialization easier composable (before entering Read loop) * Remove use of deprecated boost::asio::null_buffers and boost::beast::ssl_stream (cherry picked from commit e8b2be3527c7683e8bfca70ed7706fc20da566fd) --- src/server/bnetserver/Server/SessionManager.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/server/bnetserver/Server/SessionManager.cpp') diff --git a/src/server/bnetserver/Server/SessionManager.cpp b/src/server/bnetserver/Server/SessionManager.cpp index cb56972a9c2..4c5b532ee60 100644 --- a/src/server/bnetserver/Server/SessionManager.cpp +++ b/src/server/bnetserver/Server/SessionManager.cpp @@ -16,7 +16,6 @@ */ #include "SessionManager.h" -#include "DatabaseEnv.h" #include "Util.h" bool Battlenet::SessionManager::StartNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, int threadCount) @@ -24,18 +23,16 @@ bool Battlenet::SessionManager::StartNetwork(Trinity::Asio::IoContext& ioContext if (!BaseSocketMgr::StartNetwork(ioContext, bindIp, port, threadCount)) return false; - _acceptor->AsyncAcceptWithCallback<&OnSocketAccept>(); + _acceptor->AsyncAccept([this](Trinity::Net::IoContextTcpSocket&& sock, uint32 threadIndex) + { + OnSocketOpen(std::move(sock), threadIndex); + }); return true; } -NetworkThread* Battlenet::SessionManager::CreateThreads() const +Trinity::Net::NetworkThread* Battlenet::SessionManager::CreateThreads() const { - return new NetworkThread[GetNetworkThreadCount()]; -} - -void Battlenet::SessionManager::OnSocketAccept(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex) -{ - sSessionMgr.OnSocketOpen(std::move(sock), threadIndex); + return new Trinity::Net::NetworkThread[GetNetworkThreadCount()]; } Battlenet::SessionManager& Battlenet::SessionManager::Instance() -- cgit v1.2.3