mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
feat(Core): replace ACE network with Boost.Asio (#6574)
This commit is contained in:
@@ -4,58 +4,43 @@
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
/** \addtogroup u2w User to World Communication
|
||||
* @{
|
||||
* \file WorldSocketMgr.h
|
||||
* \author Derex <derex101@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef __WORLDSOCKETMGR_H
|
||||
#define __WORLDSOCKETMGR_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "SocketMgr.h"
|
||||
|
||||
class WorldSocket;
|
||||
class ReactorRunnable;
|
||||
class ACE_Event_Handler;
|
||||
|
||||
/// Manages all sockets connected to peers and network threads
|
||||
class WorldSocketMgr
|
||||
class AC_GAME_API WorldSocketMgr : public SocketMgr<WorldSocket>
|
||||
{
|
||||
public:
|
||||
friend class WorldSocket;
|
||||
typedef SocketMgr<WorldSocket> BaseSocketMgr;
|
||||
|
||||
static WorldSocketMgr* instance();
|
||||
public:
|
||||
static WorldSocketMgr& Instance();
|
||||
|
||||
/// Start network, listen at address:port .
|
||||
int StartNetwork(uint16 port, const char* address);
|
||||
bool StartWorldNetwork(Acore::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, int networkThreads);
|
||||
|
||||
/// Stops all network threads, It will wait for all running threads .
|
||||
void StopNetwork();
|
||||
void StopNetwork() override;
|
||||
|
||||
/// Wait untill all network threads have "joined" .
|
||||
void Wait();
|
||||
void OnSocketOpen(tcp::socket&& sock, uint32 threadIndex) override;
|
||||
|
||||
private:
|
||||
int OnSocketOpen(WorldSocket* sock);
|
||||
std::size_t GetApplicationSendBufferSize() const { return _socketApplicationSendBufferSize; }
|
||||
|
||||
int StartReactiveIO(uint16 port, const char* address);
|
||||
|
||||
private:
|
||||
protected:
|
||||
WorldSocketMgr();
|
||||
virtual ~WorldSocketMgr();
|
||||
|
||||
ReactorRunnable* m_NetThreads;
|
||||
size_t m_NetThreadsCount;
|
||||
NetworkThread<WorldSocket>* CreateThreads() const override;
|
||||
|
||||
int m_SockOutKBuff;
|
||||
int m_SockOutUBuff;
|
||||
bool m_UseNoDelay;
|
||||
|
||||
class WorldSocketAcceptor* m_Acceptor;
|
||||
private:
|
||||
int32 _socketSystemSendBufferSize;
|
||||
int32 _socketApplicationSendBufferSize;
|
||||
bool _tcpNoDelay;
|
||||
};
|
||||
|
||||
#define sWorldSocketMgr WorldSocketMgr::instance()
|
||||
#define sWorldSocketMgr WorldSocketMgr::Instance()
|
||||
|
||||
#endif
|
||||
/// @}
|
||||
|
||||
Reference in New Issue
Block a user