Files
TCPlayerbotCore/src/game/WorldSocketMgr.h
T

81 lines
2.1 KiB
C++
Raw Normal View History

2008-10-02 16:23:55 -05:00
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
2008-10-02 16:23:55 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2008-10-14 11:57:03 -05:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-02 16:23:55 -05:00
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2008-10-14 11:57:03 -05:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
/** \addtogroup u2w User to World Communication
* @{
* \file WorldSocketMgr.h
* \author Derex <[email protected]>
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#ifndef __WORLDSOCKETMGR_H
#define __WORLDSOCKETMGR_H
2009-10-17 15:51:44 -07:00
#include <ace/Basic_Types.h>
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
class WorldSocket;
class ReactorRunnable;
class ACE_Event_Handler;
2009-10-17 15:51:44 -07:00
/// Manages all sockets connected to peers and network threads
class WorldSocketMgr
2008-10-02 16:23:55 -05:00
{
public:
friend class WorldSocket;
friend class ACE_Singleton<WorldSocketMgr,ACE_Thread_Mutex>;
2009-10-17 15:51:44 -07:00
/// Start network, listen at address:port .
int StartNetwork (ACE_UINT16 port, const char* address);
2009-10-17 15:51:44 -07:00
/// Stops all network threads, It will wait for all running threads .
void StopNetwork ();
2009-10-17 15:51:44 -07:00
/// Wait untill all network threads have "joined" .
void Wait ();
2009-10-17 15:51:44 -07:00
/// Make this class singleton .
static WorldSocketMgr* Instance ();
2009-10-17 15:51:44 -07:00
private:
int OnSocketOpen(WorldSocket* sock);
2009-10-17 15:51:44 -07:00
int StartReactiveIO(ACE_UINT16 port, const char* address);
2009-10-17 15:51:44 -07:00
private:
WorldSocketMgr ();
virtual ~WorldSocketMgr ();
2009-10-17 15:51:44 -07:00
ReactorRunnable* m_NetThreads;
size_t m_NetThreadsCount;
2009-10-17 15:51:44 -07:00
int m_SockOutKBuff;
int m_SockOutUBuff;
bool m_UseNoDelay;
2009-10-17 15:51:44 -07:00
ACE_Event_Handler* m_Acceptor;
2008-10-02 16:23:55 -05:00
};
2009-10-17 15:51:44 -07:00
#define sWorldSocketMgr WorldSocketMgr::Instance ()
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#endif
/// @}
2009-02-17 20:07:49 -06:00