2 * Copyright (C) 2005-2009 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>
33 class ReactorRunnable
;
34 class ACE_Event_Handler
;
36 /// Manages all sockets connected to peers and network threads
40 friend class WorldSocket
;
41 friend class ACE_Singleton
<WorldSocketMgr
,ACE_Thread_Mutex
>;
43 /// Start network, listen at address:port .
44 int StartNetwork (ACE_UINT16 port
, const char* address
);
46 /// Stops all network threads, It will wait for all running threads .
49 /// Wait untill all network threads have "joined" .
52 /// Make this class singleton .
53 static WorldSocketMgr
* Instance ();
56 int OnSocketOpen(WorldSocket
* sock
);
58 int StartReactiveIO(ACE_UINT16 port
, const char* address
);
62 virtual ~WorldSocketMgr ();
64 ReactorRunnable
* m_NetThreads
;
65 size_t m_NetThreadsCount
;
71 ACE_Event_Handler
* m_Acceptor
;
74 #define sWorldSocketMgr WorldSocketMgr::Instance ()