Fixed error reporting (temporary fix).

This commit is contained in:
lotodore
2007-05-05 21:40:24 +00:00
parent 9a10079f44
commit 476035f791
3 changed files with 19 additions and 11 deletions
+7 -9
View File
@@ -50,9 +50,6 @@ ServerRecvStateInit::Instance()
ServerRecvStateInit::ServerRecvStateInit() ServerRecvStateInit::ServerRecvStateInit()
: m_curUniquePlayerId(0) : m_curUniquePlayerId(0)
{ {
boost::microsec_timer::time_duration_type dur;
boost::microsec_timer t(dur);
t.start();
} }
ServerRecvStateInit::~ServerRecvStateInit() ServerRecvStateInit::~ServerRecvStateInit()
@@ -90,6 +87,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
if (session.get()) if (session.get())
{ {
//server.CloseSessionDelayed(session); //server.CloseSessionDelayed(session);
Thread::Msleep(10);
return retVal; return retVal;
} }
} }
@@ -100,7 +98,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
// Session should be in initial state. // Session should be in initial state.
if (session->GetState() != SessionData::Init) if (session->GetState() != SessionData::Init)
{ {
//server.SessionError(session, ERR_SOCK_INVALID_STATE); server.SessionError(session, ERR_SOCK_INVALID_STATE);
return retVal; return retVal;
} }
@@ -108,7 +106,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
const NetPacketJoinGame *tmpPacket = packet->ToNetPacketJoinGame(); const NetPacketJoinGame *tmpPacket = packet->ToNetPacketJoinGame();
if (!tmpPacket) if (!tmpPacket)
{ {
//server.SessionError(session, ERR_SOCK_INVALID_PACKET); server.SessionError(session, ERR_SOCK_INVALID_PACKET);
return retVal; return retVal;
} }
@@ -118,14 +116,14 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
// Check the protocol version. // Check the protocol version.
if (joinGameData.versionMajor != NET_VERSION_MAJOR) if (joinGameData.versionMajor != NET_VERSION_MAJOR)
{ {
//server.SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED); server.SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED);
return retVal; return retVal;
} }
// Check the server password. // Check the server password.
if (!server.CheckPassword(joinGameData.password)) if (!server.CheckPassword(joinGameData.password))
{ {
//server.SessionError(session, ERR_NET_INVALID_PASSWORD); server.SessionError(session, ERR_NET_INVALID_PASSWORD);
return retVal; return retVal;
} }
@@ -134,14 +132,14 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
// Check the number of players. // Check the number of players.
if (curNumPlayers >= (size_t)server.GetGameData().numberOfPlayers) if (curNumPlayers >= (size_t)server.GetGameData().numberOfPlayers)
{ {
//server.SessionError(session, ERR_NET_SERVER_FULL); server.SessionError(session, ERR_NET_SERVER_FULL);
return retVal; return retVal;
} }
// Check whether this player is already connected. // Check whether this player is already connected.
if (server.IsPlayerConnected(joinGameData.playerName)) if (server.IsPlayerConnected(joinGameData.playerName))
{ {
//server.SessionError(session, ERR_NET_PLAYER_NAME_IN_USE); server.SessionError(session, ERR_NET_PLAYER_NAME_IN_USE);
return retVal; return retVal;
} }
+7
View File
@@ -296,6 +296,13 @@ ServerRecvThread::AddSession(boost::shared_ptr<SessionData> sessionData)
m_sessionMap.insert(pos, SocketSessionMap::value_type(sessionData->GetSocket(), sessionData)); m_sessionMap.insert(pos, SocketSessionMap::value_type(sessionData->GetSocket(), sessionData));
} }
void
ServerRecvThread::SessionError(boost::shared_ptr<SessionData> sessionData, int errorCode)
{
assert(sessionData.get());
SendError(errorCode, sessionData->GetSocket());
}
SenderThread & SenderThread &
ServerRecvThread::GetSender() ServerRecvThread::GetSender()
{ {
+5 -2
View File
@@ -51,8 +51,6 @@ public:
void Init(const std::string &pwd, const GameData &gameData); void Init(const std::string &pwd, const GameData &gameData);
void SendError(int errorCode, SOCKET s);
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet);
void AddConnection(boost::shared_ptr<ConnectData> data); void AddConnection(boost::shared_ptr<ConnectData> data);
void AddNotification(unsigned notification); void AddNotification(unsigned notification);
@@ -79,6 +77,10 @@ protected:
boost::shared_ptr<SessionData> GetSession(SOCKET sock); boost::shared_ptr<SessionData> GetSession(SOCKET sock);
void AddSession(boost::shared_ptr<SessionData> sessionData); void AddSession(boost::shared_ptr<SessionData> sessionData);
void SessionError(boost::shared_ptr<SessionData> sessionData, int errorCode);
void SendError(int errorCode, SOCKET s);
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet);
SenderThread &GetSender(); SenderThread &GetSender();
ReceiverHelper &GetReceiver(); ReceiverHelper &GetReceiver();
@@ -114,6 +116,7 @@ private:
ServerCallback &m_callback; ServerCallback &m_callback;
friend class ServerRecvStateInit; friend class ServerRecvStateInit;
friend class ServerRecvStateStartGame;
}; };
#endif #endif