More restructuring. Still broken.

This commit is contained in:
lotodore
2009-05-10 22:21:20 +00:00
parent 2541f28ff2
commit 8ab2fed1a2
13 changed files with 51 additions and 51 deletions
+4 -4
View File
@@ -73,8 +73,8 @@ HEADERS += \
src/net/netpacket.h \ src/net/netpacket.h \
src/net/resolverthread.h \ src/net/resolverthread.h \
src/net/senderinterface.h \ src/net/senderinterface.h \
src/net/senderthread.h \ src/net/senderhelper.h \
src/net/serveracceptmanager.h \ src/net/serveraccepthelper.h \
src/net/servergamethread.h \ src/net/servergamethread.h \
src/net/servergamestate.h \ src/net/servergamestate.h \
src/net/serverlobbythread.h \ src/net/serverlobbythread.h \
@@ -168,11 +168,11 @@ SOURCES += \
src/net/common/netpacket.cpp \ src/net/common/netpacket.cpp \
src/net/common/resolverthread.cpp \ src/net/common/resolverthread.cpp \
src/net/common/senderinterface.cpp \ src/net/common/senderinterface.cpp \
src/net/common/senderthread.cpp \ src/net/common/senderhelper.cpp \
src/net/common/sendercallback.cpp \ src/net/common/sendercallback.cpp \
src/net/common/servercontext.cpp \ src/net/common/servercontext.cpp \
src/net/common/serverexception.cpp \ src/net/common/serverexception.cpp \
src/net/common/serveracceptmanager.cpp \ src/net/common/serveraccepthelper.cpp \
src/net/common/servergamethread.cpp \ src/net/common/servergamethread.cpp \
src/net/common/servergamestate.cpp \ src/net/common/servergamestate.cpp \
src/net/common/serverlobbythread.cpp \ src/net/common/serverlobbythread.cpp \
+1 -1
View File
@@ -233,7 +233,7 @@ private:
mutable boost::mutex m_curStatsMutex; mutable boost::mutex m_curStatsMutex;
ServerStats m_curStats; ServerStats m_curStats;
boost::shared_ptr<SenderInterface> m_senderThread; boost::shared_ptr<SenderInterface> m_senderHelper;
friend class AbstractClientStateReceiving; friend class AbstractClientStateReceiving;
friend class ClientStateInit; friend class ClientStateInit;
+1 -1
View File
@@ -20,7 +20,7 @@
#include <net/clientstate.h> #include <net/clientstate.h>
#include <net/clientthread.h> #include <net/clientthread.h>
#include <net/clientcontext.h> #include <net/clientcontext.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/receiverhelper.h> #include <net/receiverhelper.h>
#include <net/netpacket.h> #include <net/netpacket.h>
#include <net/resolverthread.h> #include <net/resolverthread.h>
+3 -3
View File
@@ -22,7 +22,7 @@
#include <net/clientthread.h> #include <net/clientthread.h>
#include <net/clientstate.h> #include <net/clientstate.h>
#include <net/clientcontext.h> #include <net/clientcontext.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/receiverhelper.h> #include <net/receiverhelper.h>
#include <net/downloaderthread.h> #include <net/downloaderthread.h>
#include <net/clientexception.h> #include <net/clientexception.h>
@@ -70,7 +70,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager)
m_receiver.reset(new ReceiverHelper); m_receiver.reset(new ReceiverHelper);
myQtToolsInterface.reset(CreateQtToolsWrapper()); myQtToolsInterface.reset(CreateQtToolsWrapper());
m_senderCallback.reset(new ClientSenderCallback()); m_senderCallback.reset(new ClientSenderCallback());
m_senderThread.reset(new SenderThread(*m_senderCallback, m_ioService)); m_senderHelper.reset(new SenderHelper(*m_senderCallback, m_ioService));
} }
ClientThread::~ClientThread() ClientThread::~ClientThread()
@@ -737,7 +737,7 @@ ClientThread::CreateContextSession()
GetContext().SetSessionData(boost::shared_ptr<SessionData>(new SessionData( GetContext().SetSessionData(boost::shared_ptr<SessionData>(new SessionData(
newSock, newSock,
SESSION_ID_GENERIC, SESSION_ID_GENERIC,
m_senderThread, m_senderHelper,
*m_senderCallback))); *m_senderCallback)));
validSocket = true; validSocket = true;
} catch (...) } catch (...)
@@ -18,7 +18,7 @@
***************************************************************************/ ***************************************************************************/
#include <net/socket_helper.h> #include <net/socket_helper.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/sendercallback.h> #include <net/sendercallback.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
#include <core/loghelper.h> #include <core/loghelper.h>
@@ -91,17 +91,17 @@ SendDataManager::AsyncSendNextPacket(bool handlerMode)
} }
} }
SenderThread::SenderThread(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService) SenderHelper::SenderHelper(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
: m_callback(cb), m_ioService(ioService) : m_callback(cb), m_ioService(ioService)
{ {
} }
SenderThread::~SenderThread() SenderHelper::~SenderHelper()
{ {
} }
void void
SenderThread::Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet) SenderHelper::Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet)
{ {
if (packet.get() && session.get()) if (packet.get() && session.get())
{ {
@@ -129,7 +129,7 @@ SenderThread::Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<Net
} }
void void
SenderThread::Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList) SenderHelper::Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList)
{ {
if (!packetList.empty() && session.get()) if (!packetList.empty() && session.get())
{ {
@@ -165,14 +165,14 @@ SenderThread::Send(boost::shared_ptr<SessionData> session, const NetPacketList &
} }
void void
SenderThread::SignalSessionTerminated(unsigned sessionId) SenderHelper::SignalSessionTerminated(unsigned sessionId)
{ {
boost::mutex::scoped_lock lock(m_removedSessionsMutex); boost::mutex::scoped_lock lock(m_removedSessionsMutex);
m_removedSessions.push_back(sessionId); m_removedSessions.push_back(sessionId);
} }
void void
SenderThread::Process() SenderHelper::Process()
{ {
// Close sessions if they were destructed. // Close sessions if they were destructed.
{ {
@@ -17,7 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <net/serveracceptmanager.h> #include <net/serveraccepthelper.h>
#include <net/serverlobbythread.h> #include <net/serverlobbythread.h>
#include <net/serverexception.h> #include <net/serverexception.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
@@ -29,18 +29,18 @@
using namespace std; using namespace std;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
ServerAcceptManager::ServerAcceptManager(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService) ServerAcceptHelper::ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService)
: m_ioService(ioService), m_serverCallback(serverCallback) : m_ioService(ioService), m_serverCallback(serverCallback)
{ {
m_acceptor.reset(new tcp::acceptor(*m_ioService)); m_acceptor.reset(new tcp::acceptor(*m_ioService));
} }
ServerAcceptManager::~ServerAcceptManager() ServerAcceptHelper::~ServerAcceptHelper()
{ {
} }
void void
ServerAcceptManager::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread) ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread)
{ {
m_lobbyThread = lobbyThread; m_lobbyThread = lobbyThread;
@@ -63,7 +63,7 @@ ServerAcceptManager::Listen(unsigned serverPort, bool ipv6, bool sctp, const str
} }
void void
ServerAcceptManager::InternalListen(unsigned serverPort, bool ipv6, bool sctp) ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
{ {
if (serverPort < 1024) if (serverPort < 1024)
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0); throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
@@ -89,13 +89,13 @@ ServerAcceptManager::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService)); boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService));
m_acceptor->async_accept( m_acceptor->async_accept(
*newSocket, *newSocket,
boost::bind(&ServerAcceptManager::HandleAccept, this, newSocket, boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket,
boost::asio::placeholders::error) boost::asio::placeholders::error)
); );
} }
void void
ServerAcceptManager::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket> acceptedSocket, ServerAcceptHelper::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket> acceptedSocket,
const boost::system::error_code& error) const boost::system::error_code& error)
{ {
if (!error) if (!error)
@@ -109,7 +109,7 @@ ServerAcceptManager::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket
boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService)); boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService));
m_acceptor->async_accept( m_acceptor->async_accept(
*newSocket, *newSocket,
boost::bind(&ServerAcceptManager::HandleAccept, this, newSocket, boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket,
boost::asio::placeholders::error) boost::asio::placeholders::error)
); );
} }
@@ -122,13 +122,13 @@ ServerAcceptManager::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket
} }
ServerCallback & ServerCallback &
ServerAcceptManager::GetCallback() ServerAcceptHelper::GetCallback()
{ {
return m_serverCallback; return m_serverCallback;
} }
ServerLobbyThread & ServerLobbyThread &
ServerAcceptManager::GetLobbyThread() ServerAcceptHelper::GetLobbyThread()
{ {
assert(m_lobbyThread.get()); assert(m_lobbyThread.get());
return *m_lobbyThread; return *m_lobbyThread;
+1 -1
View File
@@ -21,7 +21,7 @@
#include <net/servergamethread.h> #include <net/servergamethread.h>
#include <net/serverlobbythread.h> #include <net/serverlobbythread.h>
#include <net/receiverhelper.h> #include <net/receiverhelper.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/netpacket.h> #include <net/netpacket.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
#include <net/serverexception.h> #include <net/serverexception.h>
+1 -1
View File
@@ -21,7 +21,7 @@
#include <net/servergamestate.h> #include <net/servergamestate.h>
#include <net/serverlobbythread.h> #include <net/serverlobbythread.h>
#include <net/serverexception.h> #include <net/serverexception.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/receiverhelper.h> #include <net/receiverhelper.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
#include <core/loghelper.h> #include <core/loghelper.h>
+2 -2
View File
@@ -20,7 +20,7 @@
#include <net/serverlobbythread.h> #include <net/serverlobbythread.h>
#include <net/servergamethread.h> #include <net/servergamethread.h>
#include <net/serverexception.h> #include <net/serverexception.h>
#include <net/senderthread.h> #include <net/senderhelper.h>
#include <net/sendercallback.h> #include <net/sendercallback.h>
#include <net/receiverhelper.h> #include <net/receiverhelper.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
@@ -93,7 +93,7 @@ ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ConfigFile *playerConfig
m_statDataChanged(false), m_startTime(boost::posix_time::second_clock::local_time()) m_statDataChanged(false), m_startTime(boost::posix_time::second_clock::local_time())
{ {
m_senderCallback.reset(new ServerSenderCallback(*this)); m_senderCallback.reset(new ServerSenderCallback(*this));
m_sender.reset(new SenderThread(*m_senderCallback, m_ioService)); m_sender.reset(new SenderHelper(*m_senderCallback, m_ioService));
m_receiver.reset(new ReceiverHelper); m_receiver.reset(new ReceiverHelper);
} }
+7 -7
View File
@@ -23,7 +23,7 @@
#include <net/ircthread.h> #include <net/ircthread.h>
#include <net/connectdata.h> #include <net/connectdata.h>
#include <net/serverlobbythread.h> #include <net/serverlobbythread.h>
#include <net/serveracceptmanager.h> #include <net/serveraccepthelper.h>
#include <net/serverexception.h> #include <net/serverexception.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
#include <net/socket_startup.h> #include <net/socket_startup.h>
@@ -54,15 +54,15 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, cons
if (mode & NETWORK_MODE_TCP) if (mode & NETWORK_MODE_TCP)
{ {
boost::shared_ptr<ServerAcceptManager> tcpAcceptThread(new ServerAcceptManager(GetGui(), m_ioService)); boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
tcpAcceptThread->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread); tcpAcceptHelper->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
m_acceptManagerPool.push_back(tcpAcceptThread); m_acceptHelperPool.push_back(tcpAcceptHelper);
} }
if (mode & NETWORK_MODE_SCTP) if (mode & NETWORK_MODE_SCTP)
{ {
boost::shared_ptr<ServerAcceptManager> sctpAcceptThread(new ServerAcceptManager(GetGui(), m_ioService)); boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
sctpAcceptThread->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread); sctpAcceptHelper->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
m_acceptManagerPool.push_back(sctpAcceptThread); m_acceptHelperPool.push_back(sctpAcceptHelper);
} }
m_ircThread = ircThread; m_ircThread = ircThread;
} }
@@ -18,8 +18,8 @@
***************************************************************************/ ***************************************************************************/
/* Network sender thread. */ /* Network sender thread. */
#ifndef _SENDERTHREAD_H_ #ifndef _SENDERHELPER_H_
#define _SENDERTHREAD_H_ #define _SENDERHELPER_H_
#include <net/senderinterface.h> #include <net/senderinterface.h>
#include <net/netpacket.h> #include <net/netpacket.h>
@@ -28,11 +28,11 @@
class SessionData; class SessionData;
class SendDataManager; class SendDataManager;
class SenderThread : public SenderInterface class SenderHelper : public SenderInterface
{ {
public: public:
SenderThread(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService); SenderHelper(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
virtual ~SenderThread(); virtual ~SenderHelper();
virtual void Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet); virtual void Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
virtual void Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList); virtual void Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList);
@@ -16,10 +16,10 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
/* Network server manager to accept connections. */ /* Network server helper to accept connections. */
#ifndef _SERVERACCEPTMANAGER_H_ #ifndef _SERVERACCEPTHELPER_H_
#define _SERVERACCEPTMANAGER_H_ #define _SERVERACCEPTHELPER_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <string> #include <string>
@@ -29,11 +29,11 @@
class ServerLobbyThread; class ServerLobbyThread;
class ServerAcceptManager class ServerAcceptHelper
{ {
public: public:
ServerAcceptManager(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService); ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService);
virtual ~ServerAcceptManager(); virtual ~ServerAcceptHelper();
// Set the parameters. // Set the parameters.
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd, const std::string &logDir, void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd, const std::string &logDir,
+3 -3
View File
@@ -30,7 +30,7 @@
#include <gui/guiinterface.h> #include <gui/guiinterface.h>
class ServerLobbyThread; class ServerLobbyThread;
class ServerAcceptManager; class ServerAcceptHelper;
class SenderThread; class SenderThread;
class ConfigFile; class ConfigFile;
class AvatarManager; class AvatarManager;
@@ -67,7 +67,7 @@ public:
virtual void SignalIrcServerError(int errorCode); virtual void SignalIrcServerError(int errorCode);
protected: protected:
typedef std::list<boost::shared_ptr<ServerAcceptManager> > AcceptManagerList; typedef std::list<boost::shared_ptr<ServerAcceptHelper> > AcceptHelperList;
ServerLobbyThread &GetLobbyThread(); ServerLobbyThread &GetLobbyThread();
@@ -82,7 +82,7 @@ private:
boost::shared_ptr<ServerLobbyThread> m_lobbyThread; boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
boost::shared_ptr<IrcThread> m_ircThread; boost::shared_ptr<IrcThread> m_ircThread;
boost::timers::portable::microsec_timer m_ircRestartTimer; boost::timers::portable::microsec_timer m_ircRestartTimer;
AcceptManagerList m_acceptManagerPool; AcceptHelperList m_acceptHelperPool;
}; };
#endif #endif