More restructuring. Still broken.
This commit is contained in:
+4
-4
@@ -73,8 +73,8 @@ HEADERS += \
|
||||
src/net/netpacket.h \
|
||||
src/net/resolverthread.h \
|
||||
src/net/senderinterface.h \
|
||||
src/net/senderthread.h \
|
||||
src/net/serveracceptmanager.h \
|
||||
src/net/senderhelper.h \
|
||||
src/net/serveraccepthelper.h \
|
||||
src/net/servergamethread.h \
|
||||
src/net/servergamestate.h \
|
||||
src/net/serverlobbythread.h \
|
||||
@@ -168,11 +168,11 @@ SOURCES += \
|
||||
src/net/common/netpacket.cpp \
|
||||
src/net/common/resolverthread.cpp \
|
||||
src/net/common/senderinterface.cpp \
|
||||
src/net/common/senderthread.cpp \
|
||||
src/net/common/senderhelper.cpp \
|
||||
src/net/common/sendercallback.cpp \
|
||||
src/net/common/servercontext.cpp \
|
||||
src/net/common/serverexception.cpp \
|
||||
src/net/common/serveracceptmanager.cpp \
|
||||
src/net/common/serveraccepthelper.cpp \
|
||||
src/net/common/servergamethread.cpp \
|
||||
src/net/common/servergamestate.cpp \
|
||||
src/net/common/serverlobbythread.cpp \
|
||||
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
mutable boost::mutex m_curStatsMutex;
|
||||
ServerStats m_curStats;
|
||||
|
||||
boost::shared_ptr<SenderInterface> m_senderThread;
|
||||
boost::shared_ptr<SenderInterface> m_senderHelper;
|
||||
|
||||
friend class AbstractClientStateReceiving;
|
||||
friend class ClientStateInit;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <net/clientstate.h>
|
||||
#include <net/clientthread.h>
|
||||
#include <net/clientcontext.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/receiverhelper.h>
|
||||
#include <net/netpacket.h>
|
||||
#include <net/resolverthread.h>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <net/clientthread.h>
|
||||
#include <net/clientstate.h>
|
||||
#include <net/clientcontext.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/receiverhelper.h>
|
||||
#include <net/downloaderthread.h>
|
||||
#include <net/clientexception.h>
|
||||
@@ -70,7 +70,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager)
|
||||
m_receiver.reset(new ReceiverHelper);
|
||||
myQtToolsInterface.reset(CreateQtToolsWrapper());
|
||||
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()
|
||||
@@ -737,7 +737,7 @@ ClientThread::CreateContextSession()
|
||||
GetContext().SetSessionData(boost::shared_ptr<SessionData>(new SessionData(
|
||||
newSock,
|
||||
SESSION_ID_GENERIC,
|
||||
m_senderThread,
|
||||
m_senderHelper,
|
||||
*m_senderCallback)));
|
||||
validSocket = true;
|
||||
} catch (...)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <net/socket_helper.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/sendercallback.h>
|
||||
#include <net/socket_msg.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)
|
||||
{
|
||||
}
|
||||
|
||||
SenderThread::~SenderThread()
|
||||
SenderHelper::~SenderHelper()
|
||||
{
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
@@ -129,7 +129,7 @@ SenderThread::Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<Net
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
@@ -165,14 +165,14 @@ SenderThread::Send(boost::shared_ptr<SessionData> session, const NetPacketList &
|
||||
}
|
||||
|
||||
void
|
||||
SenderThread::SignalSessionTerminated(unsigned sessionId)
|
||||
SenderHelper::SignalSessionTerminated(unsigned sessionId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_removedSessionsMutex);
|
||||
m_removedSessions.push_back(sessionId);
|
||||
}
|
||||
|
||||
void
|
||||
SenderThread::Process()
|
||||
SenderHelper::Process()
|
||||
{
|
||||
// Close sessions if they were destructed.
|
||||
{
|
||||
@@ -17,7 +17,7 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <net/serveracceptmanager.h>
|
||||
#include <net/serveraccepthelper.h>
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/serverexception.h>
|
||||
#include <net/socket_msg.h>
|
||||
@@ -29,18 +29,18 @@
|
||||
using namespace std;
|
||||
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_acceptor.reset(new tcp::acceptor(*m_ioService));
|
||||
}
|
||||
|
||||
ServerAcceptManager::~ServerAcceptManager()
|
||||
ServerAcceptHelper::~ServerAcceptHelper()
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -63,7 +63,7 @@ ServerAcceptManager::Listen(unsigned serverPort, bool ipv6, bool sctp, const str
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptManager::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
|
||||
ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
|
||||
{
|
||||
if (serverPort < 1024)
|
||||
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));
|
||||
m_acceptor->async_accept(
|
||||
*newSocket,
|
||||
boost::bind(&ServerAcceptManager::HandleAccept, this, newSocket,
|
||||
boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket,
|
||||
boost::asio::placeholders::error)
|
||||
);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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));
|
||||
m_acceptor->async_accept(
|
||||
*newSocket,
|
||||
boost::bind(&ServerAcceptManager::HandleAccept, this, newSocket,
|
||||
boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket,
|
||||
boost::asio::placeholders::error)
|
||||
);
|
||||
}
|
||||
@@ -122,13 +122,13 @@ ServerAcceptManager::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket
|
||||
}
|
||||
|
||||
ServerCallback &
|
||||
ServerAcceptManager::GetCallback()
|
||||
ServerAcceptHelper::GetCallback()
|
||||
{
|
||||
return m_serverCallback;
|
||||
}
|
||||
|
||||
ServerLobbyThread &
|
||||
ServerAcceptManager::GetLobbyThread()
|
||||
ServerAcceptHelper::GetLobbyThread()
|
||||
{
|
||||
assert(m_lobbyThread.get());
|
||||
return *m_lobbyThread;
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <net/servergamethread.h>
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/receiverhelper.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/netpacket.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <net/serverexception.h>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <net/servergamestate.h>
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/serverexception.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/receiverhelper.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <core/loghelper.h>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/servergamethread.h>
|
||||
#include <net/serverexception.h>
|
||||
#include <net/senderthread.h>
|
||||
#include <net/senderhelper.h>
|
||||
#include <net/sendercallback.h>
|
||||
#include <net/receiverhelper.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_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);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <net/ircthread.h>
|
||||
#include <net/connectdata.h>
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/serveracceptmanager.h>
|
||||
#include <net/serveraccepthelper.h>
|
||||
#include <net/serverexception.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <net/socket_startup.h>
|
||||
@@ -54,15 +54,15 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, cons
|
||||
|
||||
if (mode & NETWORK_MODE_TCP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptManager> tcpAcceptThread(new ServerAcceptManager(GetGui(), m_ioService));
|
||||
tcpAcceptThread->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
||||
m_acceptManagerPool.push_back(tcpAcceptThread);
|
||||
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||
tcpAcceptHelper->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(tcpAcceptHelper);
|
||||
}
|
||||
if (mode & NETWORK_MODE_SCTP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptManager> sctpAcceptThread(new ServerAcceptManager(GetGui(), m_ioService));
|
||||
sctpAcceptThread->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
||||
m_acceptManagerPool.push_back(sctpAcceptThread);
|
||||
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||
sctpAcceptHelper->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(sctpAcceptHelper);
|
||||
}
|
||||
m_ircThread = ircThread;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
***************************************************************************/
|
||||
/* Network sender thread. */
|
||||
|
||||
#ifndef _SENDERTHREAD_H_
|
||||
#define _SENDERTHREAD_H_
|
||||
#ifndef _SENDERHELPER_H_
|
||||
#define _SENDERHELPER_H_
|
||||
|
||||
#include <net/senderinterface.h>
|
||||
#include <net/netpacket.h>
|
||||
@@ -28,11 +28,11 @@
|
||||
class SessionData;
|
||||
class SendDataManager;
|
||||
|
||||
class SenderThread : public SenderInterface
|
||||
class SenderHelper : public SenderInterface
|
||||
{
|
||||
public:
|
||||
SenderThread(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~SenderThread();
|
||||
SenderHelper(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~SenderHelper();
|
||||
|
||||
virtual void Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
|
||||
virtual void Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList);
|
||||
@@ -16,10 +16,10 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 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_
|
||||
#define _SERVERACCEPTMANAGER_H_
|
||||
#ifndef _SERVERACCEPTHELPER_H_
|
||||
#define _SERVERACCEPTHELPER_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
@@ -29,11 +29,11 @@
|
||||
|
||||
class ServerLobbyThread;
|
||||
|
||||
class ServerAcceptManager
|
||||
class ServerAcceptHelper
|
||||
{
|
||||
public:
|
||||
ServerAcceptManager(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerAcceptManager();
|
||||
ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerAcceptHelper();
|
||||
|
||||
// Set the parameters.
|
||||
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd, const std::string &logDir,
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <gui/guiinterface.h>
|
||||
|
||||
class ServerLobbyThread;
|
||||
class ServerAcceptManager;
|
||||
class ServerAcceptHelper;
|
||||
class SenderThread;
|
||||
class ConfigFile;
|
||||
class AvatarManager;
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
virtual void SignalIrcServerError(int errorCode);
|
||||
|
||||
protected:
|
||||
typedef std::list<boost::shared_ptr<ServerAcceptManager> > AcceptManagerList;
|
||||
typedef std::list<boost::shared_ptr<ServerAcceptHelper> > AcceptHelperList;
|
||||
|
||||
ServerLobbyThread &GetLobbyThread();
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
||||
boost::shared_ptr<IrcThread> m_ircThread;
|
||||
boost::timers::portable::microsec_timer m_ircRestartTimer;
|
||||
AcceptManagerList m_acceptManagerPool;
|
||||
AcceptHelperList m_acceptHelperPool;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user