Game list in Lobby is now shown and updated even after joining or creating a game. Game updates will be sent by the server at all times (even during the game).

This commit is contained in:
lotodore
2007-09-29 14:05:41 +00:00
parent 390837f332
commit 3c88ba8bbe
19 changed files with 407 additions and 197 deletions
+28 -3
View File
@@ -29,6 +29,8 @@
#include <localenginefactory.h>
#include <tools.h>
#include <boost/bind.hpp>
using namespace std;
@@ -100,6 +102,22 @@ ServerGameThread::SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionD
GetSessionManager().SendToAllSessions(GetSender(), packet, state);
}
void
ServerGameThread::RemoveAllSessions()
{
// Called from lobby thread.
// Clean up ALL sessions which are left.
ServerLobbyThread &lobbyThread = GetLobbyThread();
boost::mutex::scoped_lock lock(m_sessionQueueMutex);
while (!m_sessionQueue.empty())
{
SessionWrapper tmpSession = m_sessionQueue.front();
m_sessionQueue.pop_front();
lobbyThread.RemoveSessionFromGame(tmpSession);
}
GetSessionManager().ForEach(boost::bind(&ServerLobbyThread::RemoveSessionFromGame, boost::ref(lobbyThread), _1));
}
void
ServerGameThread::Main()
{
@@ -262,7 +280,7 @@ ServerGameThread::ResetComputerPlayerList()
}
void
ServerGameThread::RemoveSession(SessionWrapper session)
ServerGameThread::GracefulRemoveSession(SessionWrapper session)
{
assert(session.sessionData.get());
GetSessionManager().RemoveSession(session.sessionData->GetSocket());
@@ -281,18 +299,25 @@ ServerGameThread::RemoveSession(SessionWrapper session)
}
}
void
ServerGameThread::ErrorRemoveSession(SessionWrapper session)
{
GetLobbyThread().RemoveSessionFromGame(session);
GracefulRemoveSession(session);
}
void
ServerGameThread::SessionError(SessionWrapper session, int errorCode)
{
assert(session.sessionData.get());
RemoveSession(session);
ErrorRemoveSession(session);
GetLobbyThread().SessionError(session, errorCode);
}
void
ServerGameThread::MoveSessionToLobby(SessionWrapper session, int reason)
{
RemoveSession(session);
GracefulRemoveSession(session);
GetLobbyThread().ReAddSession(session, reason);
}