Fixed error reporting (temporary fix).
This commit is contained in:
@@ -50,9 +50,6 @@ ServerRecvStateInit::Instance()
|
||||
ServerRecvStateInit::ServerRecvStateInit()
|
||||
: m_curUniquePlayerId(0)
|
||||
{
|
||||
boost::microsec_timer::time_duration_type dur;
|
||||
boost::microsec_timer t(dur);
|
||||
t.start();
|
||||
}
|
||||
|
||||
ServerRecvStateInit::~ServerRecvStateInit()
|
||||
@@ -90,6 +87,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
if (session.get())
|
||||
{
|
||||
//server.CloseSessionDelayed(session);
|
||||
Thread::Msleep(10);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +98,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
// Session should be in initial state.
|
||||
if (session->GetState() != SessionData::Init)
|
||||
{
|
||||
//server.SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
server.SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
const NetPacketJoinGame *tmpPacket = packet->ToNetPacketJoinGame();
|
||||
if (!tmpPacket)
|
||||
{
|
||||
//server.SessionError(session, ERR_SOCK_INVALID_PACKET);
|
||||
server.SessionError(session, ERR_SOCK_INVALID_PACKET);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -118,14 +116,14 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
// Check the protocol version.
|
||||
if (joinGameData.versionMajor != NET_VERSION_MAJOR)
|
||||
{
|
||||
//server.SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED);
|
||||
server.SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// Check the server password.
|
||||
if (!server.CheckPassword(joinGameData.password))
|
||||
{
|
||||
//server.SessionError(session, ERR_NET_INVALID_PASSWORD);
|
||||
server.SessionError(session, ERR_NET_INVALID_PASSWORD);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -134,14 +132,14 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
// Check the number of players.
|
||||
if (curNumPlayers >= (size_t)server.GetGameData().numberOfPlayers)
|
||||
{
|
||||
//server.SessionError(session, ERR_NET_SERVER_FULL);
|
||||
server.SessionError(session, ERR_NET_SERVER_FULL);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// Check whether this player is already connected.
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,6 +296,13 @@ ServerRecvThread::AddSession(boost::shared_ptr<SessionData> 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 &
|
||||
ServerRecvThread::GetSender()
|
||||
{
|
||||
|
||||
@@ -51,8 +51,6 @@ public:
|
||||
|
||||
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 AddNotification(unsigned notification);
|
||||
|
||||
@@ -79,6 +77,10 @@ protected:
|
||||
|
||||
boost::shared_ptr<SessionData> GetSession(SOCKET sock);
|
||||
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();
|
||||
ReceiverHelper &GetReceiver();
|
||||
@@ -114,6 +116,7 @@ private:
|
||||
ServerCallback &m_callback;
|
||||
|
||||
friend class ServerRecvStateInit;
|
||||
friend class ServerRecvStateStartGame;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user