Ejemplo n.º 1
0
void SessionList::ValidCheck(DWORD TickTime)
{
	UNREFERENCED_PARAMETER(TickTime);

	AutoMutex mutex(&_mutex);
	mutex.Lock();

	Session* pSession = NULL;
	for (LISTIT it = _sessionList.Begin(); it != _sessionList.End();)
	{
		pSession = *(_sessionList.GetPtr(it));

		if (pSession)
		{
			if (false == pSession->ValidCheck(TickTime))
			{
				Logger::Log("The session[%X] should be disconnected due to timeout.\n", pSession);
				pSession->Disconnect(false);
			}

			if (true == pSession->IsShutdownable())
			{
				pSession->Shutdown();
				_NetworkRef->PostNetEventMessage((WPARAM)NETEVENT_CLOSE, (LPARAM)pSession);
				it = _sessionList.Remove(it);
				continue;
			}
		}

		it = _sessionList.Next(it);
	}

}