// 重连控制连接还是数据连接 void PasClient::ConnectServer( UserSession &user, bool tcp ) { // 更新最后一次登陆的时间 user.Update( PCC_USER_LOGIN, tcp ) ; PccUser &pccuser = user.GetUser( tcp ) ; // 如果TCP连接 if ( tcp ) { pccuser._fd = _tcp_handle.connect_nonb( pccuser._srv_ip.c_str(), pccuser._srv_port, 10 ) ; if ( pccuser._fd > 0 ) { pccuser.SetWaitResp() ; } } /**else { // 数据通道 pccuser._fd = _udp_handle.connect_nonb( pccuser._srv_ip.c_str(), pccuser._srv_port, 10 ) ; if ( pccuser._fd == -1 ) return ; pccuser.SetWaitResp() ; }*/ PccUser &udpuser = user.GetUser( false ) ; udpuser.SetOffline() ; if(udpuser._fd != NULL) { CloseSocket(udpuser._fd); udpuser._fd = NULL; } // 通过TCP通道发送注册数据通道信息 if ( ! tcp ) { PccUser &tcpuser = user.GetUser(true) ; char buf[1024] = {0}; sprintf( buf, "SZ P %s|%s|%d\r\n", user.GetKey(true), _ip.c_str(), _port ) ; // 发送数据通道连接请求 SendData( tcpuser._fd, buf, strlen(buf) ) ; //OUT_SEND( pccuser._srv_ip.c_str(), pccuser._srv_port, pccuser._username.c_str(), "fd %d, Tcp fd %d Send %s", // pccuser._fd->_fd, tcpuser._fd->_fd, buf ) ; } }
BOOL LoginServer::OvertimeClear( DWORD dwDeltaTick ) { printf(" [ LoginServer::OvertimeClear dwDeltaTick= %d ] \n", dwDeltaTick); printf(" [ LoginServer::OvertimeClear size = %d ] \n", m_lsOvertimeTable.size()); WORD wIndex = 0; UserSession * pSession = NULL; for (int i = 0; i< m_lsOvertimeTable.size(); ++i) { wIndex = m_lsOvertimeTable.front(); if ( wIndex==0 ) { m_lsOvertimeTable.pop_front(); continue; } printf(" [ LoginServer::OvertimeClear wIndex = %d ] \n", wIndex); pSession = m_pUserSession[wIndex]; if ( pSession != NULL ) { printf(" [ LoginServer::OvertimeClear pSession = %d ] \n", pSession); if ( pSession->Update( dwDeltaTick ) ) { pSession->CloseSession(); } } m_lsOvertimeTable.pop_front(); } }