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
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>
35 class ReactorRunnable
;
36 class ACE_Event_Handler
;
38 /// Manages all sockets connected to peers and network threads
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 .
51 /// Wait untill all network threads have "joined" .
54 std::string
& GetBindAddress() { return m_addr
; }
55 ACE_UINT16
GetBindPort() { return m_port
; }
57 /// Make this class singleton .
58 static WorldSocketMgr
* Instance();
61 int OnSocketOpen(WorldSocket
* sock
);
62 int StartReactiveIO(ACE_UINT16 port
, const char* address
);
65 virtual ~WorldSocketMgr();
67 ReactorRunnable
* m_NetThreads
;
68 size_t m_NetThreadsCount
;
77 ACE_Event_Handler
* m_Acceptor
;
80 #define sWorldSocketMgr WorldSocketMgr::Instance()