Updated Copyright year to 2013
[getmangos.git] / src / game / WorldSocketMgr.h
blob82561e214bc8ea1e504cf5f568bfac768769bcf1
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /** \addtogroup u2w User to World Communication
20 * @{
21 * \file WorldSocketMgr.h
22 * \author Derex <derex101@gmail.com>
25 #ifndef __WORLDSOCKETMGR_H
26 #define __WORLDSOCKETMGR_H
28 #include <ace/Basic_Types.h>
29 #include <ace/Singleton.h>
30 #include <ace/Thread_Mutex.h>
32 #include <string>
34 class WorldSocket;
35 class ReactorRunnable;
36 class ACE_Event_Handler;
38 /// Manages all sockets connected to peers and network threads
39 class WorldSocketMgr
41 public:
42 friend class WorldSocket;
43 friend class ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>;
45 /// Start network, listen at address:port .
46 int StartNetwork(ACE_UINT16 port, std::string& address);
48 /// Stops all network threads, It will wait for all running threads .
49 void StopNetwork();
51 /// Wait untill all network threads have "joined" .
52 void Wait();
54 std::string& GetBindAddress() { return m_addr; }
55 ACE_UINT16 GetBindPort() { return m_port; }
57 /// Make this class singleton .
58 static WorldSocketMgr* Instance();
60 private:
61 int OnSocketOpen(WorldSocket* sock);
62 int StartReactiveIO(ACE_UINT16 port, const char* address);
64 WorldSocketMgr();
65 virtual ~WorldSocketMgr();
67 ReactorRunnable* m_NetThreads;
68 size_t m_NetThreadsCount;
70 int m_SockOutKBuff;
71 int m_SockOutUBuff;
72 bool m_UseNoDelay;
74 std::string m_addr;
75 ACE_UINT16 m_port;
77 ACE_Event_Handler* m_Acceptor;
80 #define sWorldSocketMgr WorldSocketMgr::Instance()
82 #endif
83 /// @}