Server support for unsubscribing/resubscribing of lobby messages. Not yet used by the client.

This commit is contained in:
lotodore
2008-05-11 21:41:30 +00:00
parent c60fd58ec9
commit 0ef69297d1
9 changed files with 156 additions and 25 deletions
+31
View File
@@ -150,6 +150,17 @@ SessionManager::Select(unsigned timeoutMsec)
return retSession;
}
SessionWrapper
SessionManager::GetSessionById(SessionId id) const
{
SessionWrapper tmpSession;
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::const_iterator pos = m_sessionMap.find(id);
if (pos != m_sessionMap.end())
tmpSession = pos->second;
return tmpSession;
}
SessionWrapper
SessionManager::GetSessionByPlayerName(const string playerName) const
{
@@ -365,6 +376,26 @@ SessionManager::SendToAllSessions(SenderThread &sender, boost::shared_ptr<NetPac
}
}
void
SessionManager::SendLobbyMsgToAllSessions(SenderThread &sender, boost::shared_ptr<NetPacket> packet, SessionData::State state)
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::iterator i = m_sessionMap.begin();
SessionMap::iterator end = m_sessionMap.end();
while (i != end)
{
if (!i->second.sessionData.get())
throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0);
// 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;
}
}
void
SessionManager::SendToAllButOneSessions(SenderThread &sender, boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state)
{