Pol  Revision:4b29d2b
network.h
Go to the documentation of this file.
1 #ifndef GLOBALS_NETWORK_H
2 #define GLOBALS_NETWORK_H
3 
4 #include "pol_global_config.h"
5 
6 #include <array>
7 #include <boost/noncopyable.hpp>
8 #include <memory>
9 #include <vector>
10 
11 #include "../network/bannedips.h"
12 #include "../network/iostats.h"
13 #include "../network/msghandl.h"
14 #include "../polstats.h"
15 #include "../sockio.h"
16 #include "../uoclient.h"
17 
18 namespace Pol
19 {
20 namespace Network
21 {
22 class AuxService;
23 class Client;
24 class ClientTransmit;
25 class PacketHookData;
26 class PacketsSingleton;
27 class UOClientInterface;
28 }
29 namespace threadhelp
30 {
31 class DynTaskThreadPool;
32 }
33 namespace Core
34 {
35 class MessageTypeFilter;
36 class SQLService;
38 
39 typedef std::vector<Network::Client*> Clients;
40 typedef std::vector<ServerDescription*> Servers;
41 
42 class NetworkManager : boost::noncopyable
43 {
44 public:
46  ~NetworkManager();
47 
48  void deinialize();
49  void kill_disconnected_clients();
50 
51  struct Memory;
52 
53  Memory estimateSize() const;
54 
55  Clients clients;
56  Servers servers;
57 
59 
60 #ifdef HAVE_MYSQL
61  std::unique_ptr<SQLService> sql_service;
62 #endif
63  std::unique_ptr<Network::UOClientInterface> uo_client_interface;
64 
65  std::vector<Network::AuxService*> auxservices;
66 
69  std::vector<UoClientListener> uoclient_listeners;
70 
73  std::unique_ptr<MessageTypeFilter> login_filter;
74  std::unique_ptr<MessageTypeFilter> game_filter;
75  std::unique_ptr<MessageTypeFilter> disconnected_filter;
76 
77  // stores information about each packet and its script & default handler
78  std::vector<std::unique_ptr<Network::PacketHookData>> packet_hook_data;
79  std::vector<std::unique_ptr<Network::PacketHookData>> packet_hook_data_v2;
80  // handler[] is used for storing the core MSG_HANDLER calls.
81  std::array<Network::MSG_HANDLER, 256> handler;
82  /*
83  handler_v2[] is used for storing the core MSG_HANDLER calls for packets that
84  were changed in client 6.0.1.7 (or any newer version where a second handler is
85  required due to changed incoming packet structure).
86  */
87  std::array<Network::MSG_HANDLER, 256> handler_v2;
88 
89  std::array<Network::ExtMsgHandler, 256> ext_handler_table;
90 
91  char ipaddr_str[64];
92  char lanaddr_str[64];
93  char hostname[64];
94 
95  std::unique_ptr<Network::PacketsSingleton> packetsSingleton;
96 
97  std::unique_ptr<Network::ClientTransmit> clientTransmit;
98 
99  std::unique_ptr<threadhelp::DynTaskThreadPool> auxthreadpool;
100 
101  std::vector<Network::IPRule> banned_ips;
102 
104 
105 
106  struct Memory
107  {
108  size_t client_size;
109  size_t client_count;
110  size_t misc;
111  };
112 
113 private:
114 };
115 
117 }
118 }
119 #endif
std::unique_ptr< Network::PacketsSingleton > packetsSingleton
Definition: network.h:95
std::vector< Network::Client * > Clients
Definition: network.h:37
Network::IOStats queuedmode_iostats
Definition: network.h:72
std::vector< ServerDescription * > Servers
Definition: network.h:40
std::array< Network::MSG_HANDLER, 256 > handler_v2
Definition: network.h:87
std::unique_ptr< MessageTypeFilter > disconnected_filter
Definition: network.h:75
std::vector< Network::AuxService * > auxservices
Definition: network.h:65
std::unique_ptr< SQLService > sql_service
Definition: network.h:61
std::unique_ptr< Network::UOClientInterface > uo_client_interface
Definition: network.h:63
std::vector< std::unique_ptr< Network::PacketHookData > > packet_hook_data_v2
Definition: network.h:79
std::unique_ptr< Network::ClientTransmit > clientTransmit
Definition: network.h:97
std::unique_ptr< threadhelp::DynTaskThreadPool > auxthreadpool
Definition: network.h:99
NetworkManager networkManager
Definition: network.cpp:28
std::vector< std::unique_ptr< Network::PacketHookData > > packet_hook_data
Definition: network.h:78
std::vector< Network::IPRule > banned_ips
Definition: network.h:101
std::array< Network::ExtMsgHandler, 256 > ext_handler_table
Definition: network.h:89
std::array< Network::MSG_HANDLER, 256 > handler
Definition: network.h:81
UoClientProtocol uoclient_protocol
Definition: network.h:68
Network::IOStats iostats
Definition: network.h:71
std::unique_ptr< MessageTypeFilter > login_filter
Definition: network.h:73
std::unique_ptr< MessageTypeFilter > game_filter
Definition: network.h:74
std::vector< UoClientListener > uoclient_listeners
Definition: network.h:69
Definition: berror.cpp:12
Network::PolSocket polsocket
Definition: network.h:103
UoClientGeneral uoclient_general
Definition: network.h:67