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
This commit is contained in:
Shauren
2025-04-08 19:15:16 +02:00
parent 40d80f3476
commit e8b2be3527
32 changed files with 967 additions and 811 deletions

View File

@@ -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::Session>* Battlenet::SessionManager::CreateThreads() const
Trinity::Net::NetworkThread<Battlenet::Session>* Battlenet::SessionManager::CreateThreads() const
{
return new NetworkThread<Session>[GetNetworkThreadCount()];
}
void Battlenet::SessionManager::OnSocketAccept(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex)
{
sSessionMgr.OnSocketOpen(std::move(sock), threadIndex);
return new Trinity::Net::NetworkThread<Session>[GetNetworkThreadCount()];
}
Battlenet::SessionManager& Battlenet::SessionManager::Instance()