Preparing to rename some of the network engine files.

This commit is contained in:
lotodore
2007-08-15 13:36:29 +00:00
parent 59b7438376
commit 913f9db110
3 changed files with 30 additions and 30 deletions
+20 -20
View File
@@ -30,19 +30,19 @@
using namespace std;
ServerThread::ServerThread(GuiInterface &gui, ConfigFile *config)
ServerAcceptThread::ServerAcceptThread(GuiInterface &gui, ConfigFile *config)
: m_gui(gui)
{
m_context.reset(new ServerContext);
m_recvThread.reset(new ServerRecvThread(gui, config));
m_lobbyThread.reset(new ServerLobbyThread(gui, config));
}
ServerThread::~ServerThread()
ServerAcceptThread::~ServerAcceptThread()
{
}
void
ServerThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd,
ServerAcceptThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd,
const GameData &gameData)
{
if (IsRunning())
@@ -54,28 +54,28 @@ ServerThread::Init(unsigned serverPort, bool ipv6, bool sctp, const std::string
context.SetAddrFamily(ipv6 ? AF_INET6 : AF_INET);
context.SetServerPort(serverPort);
GetRecvThread().Init(pwd, gameData);
GetLobbyThread().Init(pwd);
}
ServerCallback &
ServerThread::GetCallback()
ServerAcceptThread::GetCallback()
{
return m_gui;
}
GuiInterface &
ServerThread::GetGui()
ServerAcceptThread::GetGui()
{
return m_gui;
}
void
ServerThread::Main()
ServerAcceptThread::Main()
{
try
{
Listen();
GetRecvThread().Run();
GetLobbyThread().Run();
while (!ShouldTerminate())
{
@@ -86,12 +86,12 @@ ServerThread::Main()
{
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
}
GetRecvThread().SignalTermination();
GetRecvThread().Join(RECEIVER_THREAD_TERMINATE_TIMEOUT);
GetLobbyThread().SignalTermination();
GetLobbyThread().Join(LOBBY_THREAD_TERMINATE_TIMEOUT);
}
void
ServerThread::Listen()
ServerAcceptThread::Listen()
{
ServerContext &context = GetContext();
@@ -147,7 +147,7 @@ ServerThread::Listen()
}
void
ServerThread::AcceptLoop()
ServerAcceptThread::AcceptLoop()
{
ServerContext &context = GetContext();
@@ -174,28 +174,28 @@ ServerThread::AcceptLoop()
throw ServerException(ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
}
GetRecvThread().AddConnection(tmpData);
GetLobbyThread().AddConnection(tmpData);
}
}
const ServerContext &
ServerThread::GetContext() const
ServerAcceptThread::GetContext() const
{
assert(m_context.get());
return *m_context;
}
ServerContext &
ServerThread::GetContext()
ServerAcceptThread::GetContext()
{
assert(m_context.get());
return *m_context;
}
ServerRecvThread &
ServerThread::GetRecvThread()
ServerLobbyThread &
ServerAcceptThread::GetLobbyThread()
{
assert(m_recvThread.get());
return *m_recvThread;
assert(m_lobbyThread.get());
return *m_lobbyThread;
}
+1 -1
View File
@@ -31,7 +31,7 @@
#include <list>
#include <core/boost/timer.hpp>
#define RECEIVER_THREAD_TERMINATE_TIMEOUT 200
#define LOBBY_THREAD_TERMINATE_TIMEOUT 200
class SenderThread;
+9 -9
View File
@@ -16,10 +16,10 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* Network server thread. */
/* Network server thread to accept connections. */
#ifndef _SERVERTHREAD_H_
#define _SERVERTHREAD_H_
#ifndef _SERVERACCEPTTHREAD_H_
#define _SERVERACCEPTTHREAD_H_
#include <game_defs.h>
#include <core/thread.h>
@@ -28,17 +28,17 @@
#include <memory>
class ServerContext;
class ServerRecvThread;
class ServerLobbyThread;
class ServerSenderCallback;
class SenderThread;
class ConfigFile;
struct GameData;
class ServerThread : public Thread
class ServerAcceptThread : public Thread
{
public:
ServerThread(GuiInterface &gui, ConfigFile *config);
virtual ~ServerThread();
ServerAcceptThread(GuiInterface &gui, ConfigFile *config);
virtual ~ServerAcceptThread();
// Set the parameters.
void Init(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd,
@@ -58,11 +58,11 @@ protected:
const ServerContext &GetContext() const;
ServerContext &GetContext();
ServerRecvThread &GetRecvThread();
ServerLobbyThread &GetLobbyThread();
private:
std::auto_ptr<ServerContext> m_context;
std::auto_ptr<ServerRecvThread> m_recvThread;
std::auto_ptr<ServerLobbyThread> m_lobbyThread;
GuiInterface &m_gui;
};