Server support for unsubscribing/resubscribing of lobby messages. Not yet used by the client.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user