C++ (Qt)void MyServer::slotUpdateUsers (){ count=0; QTcpSocket *pClient = (QTcpSocket *)sender(); QList<UserInfo*>::iterator o=user_list->begin(); for (; o != user_list->end(); ++o){//ищем пользователя count++; if(user_list->at(count)->uSocket() == pClient){ user_list->removeAt(count); } } pClient->deleteLater();}
C++ (Qt)void MyServer::slotUpdateUsers( void ){ size_t count = 0; QTcpSocket *pClient = (QTcpSocket *)sender(); while (count < user_list.size()) { if(user_list->at(count)->uSocket() == pClient) user_list->removeAt(count); else ++count; }}
/* QObject::connect(pClientSocket, SIGNAL(disconnected() ), this, SLOT(deleteLater() ) );*/
connect(pClientSocket, SIGNAL(disconnected() ), this, SLOT(deleteL() ) );
void MyLogin::deleteL(){ QTcpSocket* pSocket= (QTcpSocket*)sender(); pSocket->deleteLater();}