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 SendReportAvatar(unsigned reportedPlayerId, const std::string &avatarHash);
void StartAsyncRead(); void StartAsyncRead();
virtual void CloseSession(boost::shared_ptr<SessionData> /*session*/) { virtual void CloseSession(boost::shared_ptr<SessionData> session);
// TODO
}
virtual void HandlePacket(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet); virtual void HandlePacket(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
void SelectServer(unsigned serverId); void SelectServer(unsigned serverId);
+6
View File
@@ -365,6 +365,12 @@ ClientThread::StartAsyncRead()
GetContext().GetSessionData()->GetReceiveBuffer().StartAsyncRead(GetContext().GetSessionData()); GetContext().GetSessionData()->GetReceiveBuffer().StartAsyncRead(GetContext().GetSessionData());
} }
void
ClientThread::CloseSession(boost::shared_ptr<SessionData> session)
{
throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0);
}
void void
ClientThread::HandlePacket(boost::shared_ptr<SessionData> /*session*/, boost::shared_ptr<NetPacket> packet) 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/receivebuffer.h>
#include <net/sessiondata.h> #include <net/sessiondata.h>
#include <core/loghelper.h> #include <core/loghelper.h>
#include <core/pokerthexception.h>
#include <boost/swap.hpp> #include <boost/swap.hpp>
using namespace std; using namespace std;
@@ -68,6 +67,7 @@ ReceiveBuffer::HandleRead(boost::shared_ptr<SessionData> session, const boost::s
} }
} catch (const exception &e) { } catch (const exception &e) {
LOG_ERROR("Session " << session->GetId() << " - unhandled exception in HandleRead: " << e.what()); 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()) { while (!receivedPackets.empty()) {
boost::shared_ptr<NetPacket> p = receivedPackets.front(); boost::shared_ptr<NetPacket> p = receivedPackets.front();
receivedPackets.pop_front(); receivedPackets.pop_front();
// We need to catch specific exceptions, so that they do not affect the server. session->HandlePacket(p);
try {
session->HandlePacket(p);
} catch (const PokerTHException &e) {
LOG_ERROR("Session " << session->GetId() << " - Read handler exception: " << e.what());
// TODO add error handling, close session.
}
} }
if (recvBufUsed >= RECV_BUF_SIZE) { if (recvBufUsed >= RECV_BUF_SIZE) {
LOG_ERROR("Session " << session->GetId() << " - Receive buf full: " << recvBufUsed); LOG_ERROR("Session " << session->GetId() << " - Receive buf full: " << recvBufUsed);