void CClientReConnectManager::GetConnectInfo(vecClientConnectInfo& VecClientConnectInfo) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); VecClientConnectInfo.clear(); for (mapReactorConnectInfo::iterator b = m_mapConnectInfo.begin(); b != m_mapConnectInfo.end(); b++) { CReactorClientInfo* pClientInfo = (CReactorClientInfo*)b->second; if (NULL != pClientInfo) { if (NULL != pClientInfo->GetConnectClient()) { _ClientConnectInfo ClientConnectInfo = pClientInfo->GetConnectClient()->GetClientConnectInfo(); ClientConnectInfo.m_addrRemote = pClientInfo->GetServerAddr(); VecClientConnectInfo.push_back(ClientConnectInfo); } else { _ClientConnectInfo ClientConnectInfo; ClientConnectInfo.m_blValid = false; ClientConnectInfo.m_addrRemote = pClientInfo->GetServerAddr(); VecClientConnectInfo.push_back(ClientConnectInfo); } } } }
void CClientReConnectManager::GetConnectInfo(vecClientConnectInfo& VecClientConnectInfo) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); VecClientConnectInfo.clear(); 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) { if (NULL != pClientInfo->GetConnectClient()) { _ClientConnectInfo ClientConnectInfo = pClientInfo->GetConnectClient()->GetClientConnectInfo(); ClientConnectInfo.m_addrRemote = pClientInfo->GetServerAddr(); VecClientConnectInfo.push_back(ClientConnectInfo); } else { _ClientConnectInfo ClientConnectInfo; ClientConnectInfo.m_blValid = false; ClientConnectInfo.m_addrRemote = pClientInfo->GetServerAddr(); VecClientConnectInfo.push_back(ClientConnectInfo); } } } }
ACE_INET_Addr CClientReConnectManager::GetServerAddr(int nServerID) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); ACE_INET_Addr remote_addr; mapReactorConnectInfo::iterator f = m_mapConnectInfo.find(nServerID); if (f == m_mapConnectInfo.end()) { //如果这个链接已经存在,则不创建新的链接 OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]nServerID =(%d) is exist.\n", nServerID)); return remote_addr; } else { CReactorClientInfo* pClientInfo = (CReactorClientInfo*)f->second; remote_addr = pClientInfo->GetServerAddr(); return remote_addr; } }
bool CClientReConnectManager::GetServerIPInfo( int nServerID, _ClientIPInfo& objServerIPInfo ) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); mapReactorConnectInfo::iterator f = m_mapConnectInfo.find(nServerID); if (f == m_mapConnectInfo.end()) { //如果这个链接已经存在,则不创建新的链接 OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]nServerID =(%d) is exist.\n", nServerID)); return false; } else { CReactorClientInfo* pClientInfo = (CReactorClientInfo*)f->second; ACE_INET_Addr remote_addr = pClientInfo->GetServerAddr(); sprintf_safe(objServerIPInfo.m_szClientIP, MAX_BUFF_50, remote_addr.get_host_addr()); objServerIPInfo.m_nPort = remote_addr.get_port_number(); return true; } }
ACE_INET_Addr CClientReConnectManager::GetServerAddr(int nServerID) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); ACE_INET_Addr remote_addr; char szServerID[10] = {'\0'}; sprintf_safe(szServerID, 10, "%d", nServerID); CReactorClientInfo* pClientInfo = m_objClientTCPList.Get_Hash_Box_Data(szServerID); if (NULL == pClientInfo) { //如果这个链接不存在,则不创建新的链接 OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]nServerID =(%d) is not exist.\n", nServerID)); return remote_addr; } else { remote_addr = pClientInfo->GetServerAddr(); return remote_addr; } }
bool CClientReConnectManager::GetServerIPInfo( int nServerID, _ClientIPInfo& objServerIPInfo ) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock); char szServerID[10] = {'\0'}; sprintf_safe(szServerID, 10, "%d", nServerID); CReactorClientInfo* pClientInfo = m_objClientTCPList.Get_Hash_Box_Data(szServerID); if (NULL == pClientInfo) { //如果这个链接不存在,则不创建新的链接 OUR_DEBUG((LM_ERROR, "[CClientReConnectManager::Close]nServerID =(%d) is not exist.\n", nServerID)); return false; } else { ACE_INET_Addr remote_addr = pClientInfo->GetServerAddr(); sprintf_safe(objServerIPInfo.m_szClientIP, MAX_BUFF_50, remote_addr.get_host_addr()); objServerIPInfo.m_nPort = remote_addr.get_port_number(); return true; } }