TrinityCore
WorldSocketMgr.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
24#ifndef __WORLDSOCKETMGR_H
25#define __WORLDSOCKETMGR_H
26
27#include "SocketMgr.h"
28
29class WorldSocket;
30
32class TC_GAME_API WorldSocketMgr : public SocketMgr<WorldSocket>
33{
35
36public:
38
39 static WorldSocketMgr& Instance();
40
42 bool StartWorldNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, uint16 instancePort, int networkThreads);
43
45 void StopNetwork() override;
46
47 void OnSocketOpen(boost::asio::ip::tcp::socket&& sock, uint32 threadIndex) override;
48
49 std::size_t GetApplicationSendBufferSize() const { return _socketApplicationSendBufferSize; }
50
51protected:
53
55
56private:
57 // private, must not be called directly
58 bool StartNetwork(Trinity::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port, int threadCount) override
59 {
60 return BaseSocketMgr::StartNetwork(ioContext, bindIp, port, threadCount);
61 }
62
67};
68
69#define sWorldSocketMgr WorldSocketMgr::Instance()
70
71#endif
#define TC_GAME_API
Definition: Define.h:123
int32_t int32
Definition: Define.h:138
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
virtual void OnSocketOpen(boost::asio::ip::tcp::socket &&sock, uint32 threadIndex)
Definition: SocketMgr.h:96
virtual void StopNetwork()
Definition: SocketMgr.h:72
virtual NetworkThread< SocketType > * CreateThreads() const =0
Manages all sockets connected to peers and network threads.
int32 _socketSystemSendBufferSize
SocketMgr< WorldSocket > BaseSocketMgr
AsyncAcceptor * _instanceAcceptor
bool StartNetwork(Trinity::Asio::IoContext &ioContext, std::string const &bindIp, uint16 port, int threadCount) override
int32 _socketApplicationSendBufferSize
std::size_t GetApplicationSendBufferSize() const