mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-15 08:16:08 +00:00
feat(Core): replace ACE network with Boost.Asio (#6574)
This commit is contained in:
46
src/server/authserver/Server/AuthSocketMgr.h
Normal file
46
src/server/authserver/Server/AuthSocketMgr.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||
*/
|
||||
|
||||
#ifndef AuthSocketMgr_h__
|
||||
#define AuthSocketMgr_h__
|
||||
|
||||
#include "SocketMgr.h"
|
||||
#include "AuthSession.h"
|
||||
|
||||
class AuthSocketMgr : public SocketMgr<AuthSession>
|
||||
{
|
||||
typedef SocketMgr<AuthSession> BaseSocketMgr;
|
||||
|
||||
public:
|
||||
static AuthSocketMgr& Instance()
|
||||
{
|
||||
static AuthSocketMgr instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool StartNetwork(Acore::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, int threadCount = 1) override
|
||||
{
|
||||
if (!BaseSocketMgr::StartNetwork(ioContext, bindIp, port, threadCount))
|
||||
return false;
|
||||
|
||||
_acceptor->AsyncAcceptWithCallback<&AuthSocketMgr::OnSocketAccept>();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
NetworkThread<AuthSession>* CreateThreads() const override
|
||||
{
|
||||
return new NetworkThread<AuthSession>[1];
|
||||
}
|
||||
|
||||
static void OnSocketAccept(tcp::socket&& sock, uint32 threadIndex)
|
||||
{
|
||||
Instance().OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
|
||||
}
|
||||
};
|
||||
|
||||
#define sAuthSocketMgr AuthSocketMgr::Instance()
|
||||
|
||||
#endif // AuthSocketMgr_h__
|
||||
Reference in New Issue
Block a user