aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/bnetserver')
-rw-r--r--src/server/bnetserver/CMakeLists.txt3
-rw-r--r--src/server/bnetserver/Main.cpp14
-rw-r--r--src/server/bnetserver/Realms/RealmList.cpp11
-rw-r--r--src/server/bnetserver/Realms/RealmList.h4
-rw-r--r--src/server/bnetserver/Realms/WorldListener.cpp132
-rw-r--r--src/server/bnetserver/Realms/WorldListener.h63
-rw-r--r--src/server/bnetserver/bnetserver.conf.dist7
7 files changed, 5 insertions, 229 deletions
diff --git a/src/server/bnetserver/CMakeLists.txt b/src/server/bnetserver/CMakeLists.txt
index 81aabc3eed8..7aa861499d9 100644
--- a/src/server/bnetserver/CMakeLists.txt
+++ b/src/server/bnetserver/CMakeLists.txt
@@ -43,8 +43,7 @@ endif()
target_link_libraries(bnetserver
PUBLIC
- shared
- ipc)
+ shared)
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp
index 310683dec37..65b8d6e772b 100644
--- a/src/server/bnetserver/Main.cpp
+++ b/src/server/bnetserver/Main.cpp
@@ -36,7 +36,6 @@
#include "RealmList.h"
#include "GitRevision.h"
#include "Util.h"
-#include "ZmqContext.h"
#include "DatabaseLoader.h"
#include <cstdlib>
#include <iostream>
@@ -136,23 +135,14 @@ int main(int argc, char** argv)
}
}
- int32 worldListenPort = sConfigMgr->GetIntDefault("WorldserverListenPort", 1118);
- if (worldListenPort < 0 || worldListenPort > 0xFFFF)
- {
- TC_LOG_ERROR("server.bnetserver", "Specified worldserver listen port (%d) out of allowed range (1-65535)", worldListenPort);
- return 1;
- }
-
// Initialize the database connection
if (!StartDB())
return 1;
- sIpcContext->Initialize();
-
_ioService = new boost::asio::io_service();
// Get the list of realms for the server
- sRealmList->Initialize(*_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10), worldListenPort);
+ sRealmList->Initialize(*_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10));
// Start the listening port (acceptor) for auth connections
int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119);
@@ -209,8 +199,6 @@ int main(int argc, char** argv)
sSessionMgr.StopNetwork();
- sIpcContext->Close();
-
sRealmList->Close();
// Close the Database Pool and library
diff --git a/src/server/bnetserver/Realms/RealmList.cpp b/src/server/bnetserver/Realms/RealmList.cpp
index d3f40a8cc97..056ddef39d4 100644
--- a/src/server/bnetserver/Realms/RealmList.cpp
+++ b/src/server/bnetserver/Realms/RealmList.cpp
@@ -20,23 +20,20 @@
#include "Database/DatabaseEnv.h"
#include "SessionManager.h"
#include "Util.h"
-#include "Commands.h"
#include "RealmList.h"
#include <boost/asio/ip/tcp.hpp>
-RealmList::RealmList() : _updateInterval(0), _updateTimer(nullptr), _resolver(nullptr), _worldListener(nullptr)
+RealmList::RealmList() : _updateInterval(0), _updateTimer(nullptr), _resolver(nullptr)
{
}
RealmList::~RealmList()
{
delete _updateTimer;
- delete _resolver;
- delete _worldListener;
}
// Load the realm list from the database
-void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInterval, uint16 worldListenPort)
+void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInterval)
{
_updateInterval = updateInterval;
_updateTimer = new boost::asio::deadline_timer(ioService);
@@ -44,14 +41,10 @@ void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInte
// Get the content of the realmlist table in the database
UpdateRealms(boost::system::error_code());
-
- _worldListener = new WorldListener(worldListenPort);
- _worldListener->Start();
}
void RealmList::Close()
{
- _worldListener->End();
_updateTimer->cancel();
}
diff --git a/src/server/bnetserver/Realms/RealmList.h b/src/server/bnetserver/Realms/RealmList.h
index 388d4d5e1aa..fe3c9185ccf 100644
--- a/src/server/bnetserver/Realms/RealmList.h
+++ b/src/server/bnetserver/Realms/RealmList.h
@@ -21,7 +21,6 @@
#include "Common.h"
#include "Realm/Realm.h"
-#include "WorldListener.h"
#include <boost/asio/ip/address.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/io_service.hpp>
@@ -43,7 +42,7 @@ public:
~RealmList();
- void Initialize(boost::asio::io_service& ioService, uint32 updateInterval, uint16 worldListenPort);
+ void Initialize(boost::asio::io_service& ioService, uint32 updateInterval);
void Close();
RealmMap const& GetRealms() const { return _realms; }
@@ -60,7 +59,6 @@ private:
uint32 _updateInterval;
boost::asio::deadline_timer* _updateTimer;
boost::asio::ip::tcp::resolver* _resolver;
- WorldListener* _worldListener;
};
#define sRealmList RealmList::instance()
diff --git a/src/server/bnetserver/Realms/WorldListener.cpp b/src/server/bnetserver/Realms/WorldListener.cpp
deleted file mode 100644
index 2dd9bcdfa2f..00000000000
--- a/src/server/bnetserver/Realms/WorldListener.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Log.h"
-#include "SessionManager.h"
-#include "WoWRealmPackets.h"
-#include "ZmqContext.h"
-#include "WorldListener.h"
-
-WorldListener::HandlerTable const WorldListener::_handlers;
-
-WorldListener::HandlerTable::HandlerTable()
-{
-#define DEFINE_HANDLER(opc, func) _handlers[opc] = { func, #opc }
-
- DEFINE_HANDLER(BNET_CHANGE_TOON_ONLINE_STATE, &WorldListener::HandleToonOnlineStatusChange);
-
-#undef DEFINE_HANDLER
-}
-
-WorldListener::WorldListener(uint16 worldListenPort) : _worldListenPort(worldListenPort)
-{
- _worldSocket = sIpcContext->CreateNewSocket(zmqpp::socket_type::pull);
-}
-
-WorldListener::~WorldListener()
-{
- delete _worldSocket;
-}
-
-void WorldListener::Run()
-{
- while (!ProcessExit())
- {
- _poller->poll();
- if (_poller->events(*_worldSocket) & zmqpp::poller::poll_in)
- {
- int32 op1;
- do
- {
- zmqpp::message msg;
- _worldSocket->receive(msg);
- Dispatch(msg);
- _worldSocket->get(zmqpp::socket_option::events, op1);
- } while (op1 & zmqpp::poller::poll_in);
- }
- }
-}
-
-void WorldListener::HandleOpen()
-{
- try
- {
- _worldSocket->bind(std::string("tcp://*:") + std::to_string(_worldListenPort));
- }
- catch (zmqpp::zmq_internal_exception& ex)
- {
- TC_LOG_FATAL("server.ipc", "Could not bind to WorldserverListenPort %u. Exception: %s. Shutting down bnetserver.", _worldListenPort, ex.what());
- abort();
- }
-
- _poller->add(*_worldSocket);
- TC_LOG_INFO("server.ipc", "Listening on connections from worldservers on port %u...", _worldListenPort);
-}
-
-void WorldListener::HandleClose()
-{
- _worldSocket->close();
- TC_LOG_INFO("server.ipc", "Shutting down connections from worldservers...");
-}
-
-void WorldListener::Dispatch(zmqpp::message& msg) const
-{
- IPC::BattlenetComm::Header ipcHeader;
- msg >> ipcHeader;
-
- if (ipcHeader.Ipc.Channel != IPC_CHANNEL_BNET)
- return;
-
- if (ipcHeader.Ipc.Command < IPC_BNET_MAX_COMMAND)
- (this->*_handlers[ipcHeader.Ipc.Command].Handler)(ipcHeader.Realm, msg);
-}
-
-void WorldListener::HandleToonOnlineStatusChange(Battlenet::RealmHandle const& realm, zmqpp::message& msg) const
-{
- IPC::BattlenetComm::ToonHandle toonHandle;
- bool online;
- msg >> toonHandle;
- msg >> online;
-
- if (Battlenet::Session* session = sSessionMgr.GetSession(toonHandle.AccountId, toonHandle.GameAccountId))
- {
- if (online)
- {
- if (!session->IsToonOnline())
- {
- Battlenet::WoWRealm::ToonReady* toonReady = new Battlenet::WoWRealm::ToonReady();
- toonReady->Name.Region = realm.Region;
- toonReady->Name.ProgramId = "WoW";
- toonReady->Name.Realm = realm.GetAddress();
- toonReady->Name.Name = toonHandle.Name;
-
- toonReady->Handle.Region = realm.Region;
- toonReady->Handle.ProgramId = "WoW";
- toonReady->Handle.Realm = realm.GetAddress();
- toonReady->Handle.Id = toonHandle.Guid;
-
- session->SetToonOnline(true);
- session->AsyncWrite(toonReady);
- }
- }
- else if (session->IsToonOnline())
- {
- session->AsyncWrite(new Battlenet::WoWRealm::ToonLoggedOut());
- session->SetToonOnline(false);
- }
- }
-}
diff --git a/src/server/bnetserver/Realms/WorldListener.h b/src/server/bnetserver/Realms/WorldListener.h
deleted file mode 100644
index e5b1ff41201..00000000000
--- a/src/server/bnetserver/Realms/WorldListener.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef WorldListener_h__
-#define WorldListener_h__
-
-#include "ZMQTask.h"
-#include "Commands.h"
-
-class WorldListener : public ZMQTask
-{
-public:
- explicit WorldListener(uint16 worldListenPort);
- ~WorldListener();
- void Run() override;
-
-protected:
- void HandleOpen() override;
- void HandleClose() override;
-
-private:
- void Dispatch(zmqpp::message& msg) const;
-
- typedef void(WorldListener::*PacketHandler)(Battlenet::RealmHandle const& realm, zmqpp::message& msg) const;
- class HandlerTable
- {
- public:
- HandlerTable();
-
- struct HandlerInfo
- {
- PacketHandler Handler;
- char const* Name;
- };
-
- HandlerInfo const& operator[](uint8 opcode) const { return _handlers[opcode]; }
-
- private:
- HandlerInfo _handlers[IPC_BNET_MAX_COMMAND];
- };
-
- void HandleToonOnlineStatusChange(Battlenet::RealmHandle const& realm, zmqpp::message& msg) const;
-
- zmqpp::socket* _worldSocket;
- uint16 _worldListenPort;
- static HandlerTable const _handlers;
-};
-
-#endif // WorldListener_h__
diff --git a/src/server/bnetserver/bnetserver.conf.dist b/src/server/bnetserver/bnetserver.conf.dist
index cf5d27699d8..252a29440b5 100644
--- a/src/server/bnetserver/bnetserver.conf.dist
+++ b/src/server/bnetserver/bnetserver.conf.dist
@@ -48,13 +48,6 @@ LogsDir = ""
MaxPingTime = 30
#
-# WorldserverListenPort
-# Description: TCP port to listen on for incoming worldserver IPC.
-# Default: 1118
-
-WorldserverListenPort = 1118
-
-#
# BattlenetPort
# Description: TCP port to reach the auth server for battle.net connections.
# Default: 1119