Fixing client error messages.

This commit is contained in:
lotodore
2011-02-23 09:53:01 +00:00
parent bbe0a19340
commit 787f8d4d81
3 changed files with 9 additions and 11 deletions
+1 -3
View File
@@ -85,9 +85,7 @@ public:
void SendReportAvatar(unsigned reportedPlayerId, const std::string &avatarHash);
void StartAsyncRead();
virtual void CloseSession(boost::shared_ptr<SessionData> /*session*/) {
// TODO
}
virtual void CloseSession(boost::shared_ptr<SessionData> session);
virtual void HandlePacket(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
void SelectServer(unsigned serverId);
+6
View File
@@ -365,6 +365,12 @@ ClientThread::StartAsyncRead()
GetContext().GetSessionData()->GetReceiveBuffer().StartAsyncRead(GetContext().GetSessionData());
}
void
ClientThread::CloseSession(boost::shared_ptr<SessionData> session)
{
throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0);
}
void
ClientThread::HandlePacket(boost::shared_ptr<SessionData> /*session*/, boost::shared_ptr<NetPacket> packet)
{
+2 -8
View File
@@ -23,7 +23,6 @@
#include <net/receivebuffer.h>
#include <net/sessiondata.h>
#include <core/loghelper.h>
#include <core/pokerthexception.h>
#include <boost/swap.hpp>
using namespace std;
@@ -68,6 +67,7 @@ ReceiveBuffer::HandleRead(boost::shared_ptr<SessionData> session, const boost::s
}
} catch (const exception &e) {
LOG_ERROR("Session " << session->GetId() << " - unhandled exception in HandleRead: " << e.what());
throw;
}
}
}
@@ -109,13 +109,7 @@ ReceiveBuffer::ProcessPackets(boost::shared_ptr<SessionData> session)
while (!receivedPackets.empty()) {
boost::shared_ptr<NetPacket> p = receivedPackets.front();
receivedPackets.pop_front();
// We need to catch specific exceptions, so that they do not affect the server.
try {
session->HandlePacket(p);
} catch (const PokerTHException &e) {
LOG_ERROR("Session " << session->GetId() << " - Read handler exception: " << e.what());
// TODO add error handling, close session.
}
session->HandlePacket(p);
}
if (recvBufUsed >= RECV_BUF_SIZE) {
LOG_ERROR("Session " << session->GetId() << " - Receive buf full: " << recvBufUsed);