Fixed design problem: Thread objects can now be created in any context.

Sender thread output queue is now limited.
Server thread now terminates correctly.
Now cloning packets when sending them to multiple recipients.
Fixed one thread issue - GameStart still needs to be made thread safe.
This commit is contained in:
lotodore
2007-03-20 11:56:30 +00:00
parent 53c4af95c8
commit 804c7eaaa2
12 changed files with 160 additions and 55 deletions
+42
View File
@@ -68,6 +68,20 @@ NetPacketInit::Init()
m_data.test = htonl(0);
}
boost::shared_ptr<NetPacket>
NetPacketInit::Clone() const
{
boost::shared_ptr<NetPacket> newPacket(new NetPacketInit);
try
{
newPacket->SetData(GetData());
} catch (const NetException &)
{
// Need to return the new packet anyway.
}
return newPacket;
}
const NetPacketHeader *
NetPacketInit::GetData() const
{
@@ -118,6 +132,20 @@ NetPacketInitAck::Init()
m_data.test = htonl(0);
}
boost::shared_ptr<NetPacket>
NetPacketInitAck::Clone() const
{
boost::shared_ptr<NetPacket> newPacket(new NetPacketInitAck);
try
{
newPacket->SetData(GetData());
} catch (const NetException &)
{
// Need to return the new packet anyway.
}
return newPacket;
}
const NetPacketHeader *
NetPacketInitAck::GetData() const
{
@@ -168,6 +196,20 @@ NetPacketGameStart::Init()
m_data.test = htonl(0);
}
boost::shared_ptr<NetPacket>
NetPacketGameStart::Clone() const
{
boost::shared_ptr<NetPacket> newPacket(new NetPacketGameStart);
try
{
newPacket->SetData(GetData());
} catch (const NetException &)
{
// Need to return the new packet anyway.
}
return newPacket;
}
const NetPacketHeader *
NetPacketGameStart::GetData() const
{