void CClientProConnectManager::Close()
{
	ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock);

	//如果有定时器,关闭定时器
	CancelConnectTask();

	//关闭所有已存在的链接
	mapProactorClientInfo::iterator b = m_mapClientInfo.begin();
	mapProactorClientInfo::iterator e = m_mapClientInfo.end();
	for(b; b!= e; b++)
	{
		CProactorClientInfo* pClientInfo = (CProactorClientInfo* )b->second;
		pClientInfo->Close();
		SAFE_DELETE(pClientInfo);
	}

	mapProactorUDPClientInfo::iterator ub = m_mapProactorUDPClientInfo.begin();
	mapProactorUDPClientInfo::iterator ue = m_mapProactorUDPClientInfo.end();
	for(ub; ub!= ue; ub++)
	{
		CProactorUDPClient* pClientInfo = (CProactorUDPClient* )ub->second;
		pClientInfo->Close();
		SAFE_DELETE(pClientInfo);
	}

	m_ActiveTimer.deactivate();
	m_mapClientInfo.clear();
	m_mapProactorUDPClientInfo.clear();
}
void CClientReConnectManager::Close()
{
	ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock);
	OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]Begin.\n"));
	//如果有定时器,则删除定时器
	CancelConnectTask();

	//关闭所有已存在的链接
	for (mapReactorConnectInfo::iterator b = m_mapConnectInfo.begin(); b != m_mapConnectInfo.end(); b++)
	{
		CReactorClientInfo* pClientInfo = (CReactorClientInfo*)b->second;
		pClientInfo->Close();
		SAFE_DELETE(pClientInfo);
	}

	for (mapReactorUDPConnectInfo::iterator ub = m_mapReactorUDPConnectInfo.begin(); ub != m_mapReactorUDPConnectInfo.end(); ub++)
	{
		CReactorUDPClient* pClientInfo = (CReactorUDPClient*)ub->second;
		pClientInfo->Close();
		SAFE_DELETE(pClientInfo);
	}

	m_mapConnectInfo.clear();
	m_mapReactorUDPConnectInfo.clear();
	m_ActiveTimer.deactivate();
	OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]End.\n"));
}
bool CClientProConnectManager::StartConnectTask(int nIntervalTime)
{
	CancelConnectTask();
	m_nTaskID = m_ActiveTimer.schedule(this, (void* )NULL, ACE_OS::gettimeofday() + ACE_Time_Value(nIntervalTime), ACE_Time_Value(nIntervalTime));
	if(m_nTaskID == -1)
	{
		OUR_DEBUG((LM_ERROR, "[CClientProConnectManager::StartConnectTask].StartConnectTask is fail, time is (%d).\n", nIntervalTime));
		return false;
	}

	m_ActiveTimer.activate();
	return true;
}
Beispiel #4
0
bool CProTTyClientManager::StartConnectTask()
{
    CancelConnectTask();
    m_nTaskID = App_TimerManager::instance()->schedule(this, (void*)NULL, ACE_OS::gettimeofday() + ACE_Time_Value(m_u2TimeCheck), ACE_Time_Value(m_u2TimeCheck));

    if (m_nTaskID == -1)
    {
        OUR_DEBUG((LM_ERROR, "[CReTTyClientManager::StartConnectTask].StartConnectTask is fail, time is (%d).\n", m_u2TimeCheck));
        return false;
    }

    return true;
}
bool CClientReConnectManager::StartConnectTask(int nIntervalTime)
{
    CancelConnectTask();
    m_nTaskID = App_TimerManager::instance()->schedule(this, (void*)NULL, ACE_OS::gettimeofday() + ACE_Time_Value(nIntervalTime), ACE_Time_Value(nIntervalTime));

    if (m_nTaskID == -1)
    {
        OUR_DEBUG((LM_ERROR, "[CProConnectManager::StartConnectTask].StartConnectTask is fail, time is (%d).\n", nIntervalTime));
        return false;
    }

    m_blReactorFinish = true;
    return true;
}
void CClientReConnectManager::Close()
{
    ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock);
    OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]Begin.\n"));
    //如果有定时器,则删除定时器
    CancelConnectTask();

    //关闭所有已存在的链接
    vector<CReactorClientInfo*> vecReactorClientInfo;
    m_objClientTCPList.Get_All_Used(vecReactorClientInfo);

    for(int i = 0; i < (int)vecReactorClientInfo.size(); i++)
    {
        CReactorClientInfo* pClientInfo = vecReactorClientInfo[i];

        if(NULL != pClientInfo)
        {
            pClientInfo->GetConnectClient()->ClientClose();
            SAFE_DELETE(pClientInfo);
        }
    }

    m_objClientTCPList.Close();

    vector<CReactorUDPClient*> vecReactorUDPClient;
    m_objClientUDPList.Get_All_Used(vecReactorUDPClient);

    for(int i = 0; i < (int)vecReactorUDPClient.size(); i++)
    {
        CReactorUDPClient* pClientInfo = vecReactorUDPClient[i];

        if(NULL != pClientInfo)
        {
            pClientInfo->Close();
            SAFE_DELETE(pClientInfo);
        }
    }

    m_objClientUDPList.Close();
    m_u4MaxPoolCount = 0;

    //等待各自的连接对象自己关闭,因为不是在当前线程关闭,所以这里要等一下。
    ACE_Time_Value tvSleep(0, 10000);
    ACE_OS::sleep(tvSleep);

    OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]End.\n"));
}
Beispiel #7
0
void CProTTyClientManager::Close()
{
    ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock);

    //关闭定时器
    CancelConnectTask();

    //关闭所有已存在的链接
    vector<CProTTyHandler*> vecTTyClientHandlerInfo;
    m_objTTyClientHandlerList.Get_All_Used(vecTTyClientHandlerInfo);

    for (int i = 0; i < (int)vecTTyClientHandlerInfo.size(); i++)
    {
        CProTTyHandler* pTTyClientHandler = vecTTyClientHandlerInfo[i];

        if (NULL != pTTyClientHandler)
        {
            pTTyClientHandler->Close();
            SAFE_DELETE(pTTyClientHandler);
        }
    }

    m_objTTyClientHandlerList.Close();
}