mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-06 08:59:11 +01:00
Core/Misc: Added compatibility layer for boost 1.66 and future std:: networking stuff
* Based on work done by @dimiandre in PR #21173 Closes #21171 Closes #21173
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "PacketLog.h"
|
||||
#include "Config.h"
|
||||
#include "IpAddress.h"
|
||||
#include "Realm.h"
|
||||
#include "Timer.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "IpAddress.h"
|
||||
#include "Map.h"
|
||||
#include "Metric.h"
|
||||
#include "MiscPackets.h"
|
||||
@@ -708,7 +709,7 @@ void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket)
|
||||
void WorldSession::SendConnectToInstance(WorldPackets::Auth::ConnectToSerial serial)
|
||||
{
|
||||
boost::system::error_code ignored_error;
|
||||
boost::asio::ip::address instanceAddress = realm.GetAddressForClient(boost::asio::ip::address::from_string(GetRemoteAddress(), ignored_error));
|
||||
boost::asio::ip::address instanceAddress = realm.GetAddressForClient(Trinity::Net::make_address(GetRemoteAddress(), ignored_error));
|
||||
|
||||
_instanceConnectKey.Fields.AccountId = GetAccountId();
|
||||
_instanceConnectKey.Fields.ConnectionType = CONNECTION_TYPE_INSTANCE;
|
||||
|
||||
@@ -133,7 +133,7 @@ void WorldSocket::CheckIpCallback(PreparedQueryResult result)
|
||||
initializer.Write(ServerConnectionInitialize.c_str(), ServerConnectionInitialize.length());
|
||||
initializer.Write("\n", 1);
|
||||
|
||||
// - io_service.run thread, safe.
|
||||
// - IoContext.run thread, safe.
|
||||
QueuePacket(std::move(initializer));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,11 +58,11 @@ WorldSocketMgr& WorldSocketMgr::Instance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool WorldSocketMgr::StartWorldNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port, uint16 instancePort, int threadCount)
|
||||
bool WorldSocketMgr::StartWorldNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, uint16 instancePort, int threadCount)
|
||||
{
|
||||
_tcpNoDelay = sConfigMgr->GetBoolDefault("Network.TcpNodelay", true);
|
||||
|
||||
int const max_connections = boost::asio::socket_base::max_connections;
|
||||
int const max_connections = TRINITY_MAX_LISTEN_CONNECTIONS;
|
||||
TC_LOG_DEBUG("misc", "Max allowed socket connections %d", max_connections);
|
||||
|
||||
// -1 means use default
|
||||
@@ -76,13 +76,13 @@ bool WorldSocketMgr::StartWorldNetwork(boost::asio::io_service& service, std::st
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BaseSocketMgr::StartNetwork(service, bindIp, port, threadCount))
|
||||
if (!BaseSocketMgr::StartNetwork(ioContext, bindIp, port, threadCount))
|
||||
return false;
|
||||
|
||||
AsyncAcceptor* instanceAcceptor = nullptr;
|
||||
try
|
||||
{
|
||||
instanceAcceptor = new AsyncAcceptor(service, bindIp, instancePort);
|
||||
instanceAcceptor = new AsyncAcceptor(ioContext, bindIp, instancePort);
|
||||
}
|
||||
catch (boost::system::system_error const& err)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
static WorldSocketMgr& Instance();
|
||||
|
||||
/// Start network, listen at address:port .
|
||||
bool StartWorldNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port, uint16 instancePort, int networkThreads);
|
||||
bool StartWorldNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, uint16 instancePort, int networkThreads);
|
||||
|
||||
/// Stops all network threads, It will wait for all running threads .
|
||||
void StopNetwork() override;
|
||||
@@ -56,9 +56,9 @@ protected:
|
||||
|
||||
private:
|
||||
// private, must not be called directly
|
||||
bool StartNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port, int threadCount) override
|
||||
bool StartNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, int threadCount) override
|
||||
{
|
||||
return BaseSocketMgr::StartNetwork(service, bindIp, port, threadCount);
|
||||
return BaseSocketMgr::StartNetwork(ioContext, bindIp, port, threadCount);
|
||||
}
|
||||
|
||||
AsyncAcceptor* _instanceAcceptor;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
#include "WorldserverService.h"
|
||||
#include "BattlenetRpcErrorCodes.h"
|
||||
#include "IpAddress.h"
|
||||
#include "Log.h"
|
||||
#include "ProtobufJSON.h"
|
||||
#include "Realm.h"
|
||||
#include "RealmList.h"
|
||||
#include "RealmList.pb.h"
|
||||
#include "World.h"
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <zlib.h>
|
||||
|
||||
Battlenet::GameUtilitiesService::GameUtilitiesService(WorldSession* session) : BaseService(session)
|
||||
@@ -101,7 +101,7 @@ uint32 Battlenet::GameUtilitiesService::HandleRealmJoinRequest(std::unordered_ma
|
||||
{
|
||||
auto realmAddress = params.find("Param_RealmAddress");
|
||||
if (realmAddress != params.end())
|
||||
return sRealmList->JoinRealm(uint32(realmAddress->second->uint_value()), realm.Build, boost::asio::ip::address::from_string(_session->GetRemoteAddress()), _session->GetRealmListSecret(),
|
||||
return sRealmList->JoinRealm(uint32(realmAddress->second->uint_value()), realm.Build, Trinity::Net::make_address(_session->GetRemoteAddress()), _session->GetRealmListSecret(),
|
||||
_session->GetSessionDbcLocale(), _session->GetOS(), _session->GetAccountName(), response);
|
||||
|
||||
return ERROR_WOW_SERVICES_INVALID_JOIN_TICKET;
|
||||
|
||||
Reference in New Issue
Block a user