One sender thread per client. Requires loads of resources. Kind of hacked, because the internal dependencies are very ugly now. Requires loads of testing. A problem might be the last packet sent by the server to a specific client before closing the connection, for example an error message. It might never even reach the client, because the sender thread is terminated before. I have not yet found a good way to fix this.

This commit is contained in:
lotodore
2009-01-07 21:52:16 +00:00
parent 606158c4f0
commit d72cdb6873
16 changed files with 150 additions and 325 deletions
+6 -6
View File
@@ -357,7 +357,7 @@ SessionManager::GetRawSessionCount()
}
void
SessionManager::SendToAllSessions(SenderInterface &sender, boost::shared_ptr<NetPacket> packet, SessionData::State state)
SessionManager::SendToAllSessions(boost::shared_ptr<NetPacket> packet, SessionData::State state)
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
@@ -371,13 +371,13 @@ SessionManager::SendToAllSessions(SenderInterface &sender, boost::shared_ptr<Net
// Send each client (with a certain state) a copy of the packet.
if (i->second.sessionData->GetState() == state)
sender.Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
i->second.sessionData->GetSender().Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
++i;
}
}
void
SessionManager::SendLobbyMsgToAllSessions(SenderInterface &sender, boost::shared_ptr<NetPacket> packet, SessionData::State state)
SessionManager::SendLobbyMsgToAllSessions(boost::shared_ptr<NetPacket> packet, SessionData::State state)
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
@@ -391,13 +391,13 @@ SessionManager::SendLobbyMsgToAllSessions(SenderInterface &sender, boost::shared
// Send each client (with a certain state) a copy of the packet.
if (i->second.sessionData->GetState() == state && i->second.sessionData->WantsLobbyMsg())
sender.Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
i->second.sessionData->GetSender().Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
++i;
}
}
void
SessionManager::SendToAllButOneSessions(SenderInterface &sender, boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state)
SessionManager::SendToAllButOneSessions(boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state)
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
@@ -409,7 +409,7 @@ SessionManager::SendToAllButOneSessions(SenderInterface &sender, boost::shared_p
// Send each fully connected client but one a copy of the packet.
if (i->second.sessionData->GetState() == state)
if (i->first != except)
sender.Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
i->second.sessionData->GetSender().Send(i->second.sessionData, boost::shared_ptr<NetPacket>(packet->Clone()));
++i;
}
}