Fixed a bug in the packet handling of the client. This fixes the problem that games are not properly started, and that the player list is not properly updated.
This commit is contained in:
1 parent
1acbeba426
commit
3d57f65e2b
3 files changed
+33
-41
No files matched your search
@@ -701,30 +701,6 @@ AbstractClientStateReceiving::~AbstractClientStateReceiving()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AbstractClientStateReceiving::HandleRead(const boost::system::error_code& ec, boost::shared_ptr<ClientThread> client, size_t bytesRead)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
ReceiveBuffer &buf = client->GetContext().GetSessionData()->GetReceiveBuffer();
|
||||
buf.recvBufUsed += bytesRead;
|
||||
client->GetReceiver().ScanPackets(buf);
|
||||
|
||||
while (!buf.receivedPackets.empty())
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet = buf.receivedPackets.front();
|
||||
buf.receivedPackets.pop_front();
|
||||
if (packet)
|
||||
HandlePacket(client, packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
||||
{
|
||||
|
||||
@@ -312,9 +312,26 @@ ClientThread::StartAsyncRead()
|
||||
void
|
||||
ClientThread::HandleRead(const boost::system::error_code& ec, size_t bytesRead)
|
||||
{
|
||||
GetState().HandleRead(ec, shared_from_this(), bytesRead);
|
||||
if (!ec)
|
||||
{
|
||||
ReceiveBuffer &buf = GetContext().GetSessionData()->GetReceiveBuffer();
|
||||
buf.recvBufUsed += bytesRead;
|
||||
GetReceiver().ScanPackets(buf);
|
||||
|
||||
while (!buf.receivedPackets.empty())
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet = buf.receivedPackets.front();
|
||||
buf.receivedPackets.pop_front();
|
||||
if (packet)
|
||||
GetState().HandlePacket(shared_from_this(), packet);
|
||||
}
|
||||
StartAsyncRead();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in new issue
Block a user