Client::Client(QObject* parent) : QObject(parent), mCurrentConnectionResult(false), mOldConnectionResult(false) { mClientSocket = new QTcpSocket(this); // Таймер mActivityTimer = new QTimer(this); mActivityTimer->setInterval(mActivityInterval); // Стол - "Функция проверки активности сервера" connect(mActivityTimer, SIGNAL(timeout()), this, SLOT(slotCheckActivity())); // Слот - "Ошибка сокета" connect(mClientSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError))); // Слот - "Клиент подключен к серверу" connect(mClientSocket, SIGNAL(connected()), this, SLOT(slotClientConnected())); // Слот - "Новые данные" connect(mClientSocket, SIGNAL(readyRead()), this, SLOT(slotReceiveData())); }
Client::~Client() { // Стол - "Функция проверки активности сервера" disconnect(mActivityTimer, SIGNAL(timeout()), this, SLOT(slotCheckActivity())); // Слот - "Ошибка сокета" disconnect(mClientSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError))); // Слот - "Клиент подключен к серверу" disconnect(mClientSocket, SIGNAL(connected()), this, SLOT(slotClientConnected())); // Слот - "Новые данные" disconnect(mClientSocket, SIGNAL(readyRead()), this, SLOT(slotReceiveData())); disconnectFromServer(); }
void CentralWidget::createTcpClient() { tcpClient = new TcpClient(SERVER_NAME, SERVER_PORT, this); connect(tcpClient, SIGNAL(connected()), this, SLOT(slotClientConnected())); connect(tcpClient, SIGNAL(disconnected()), this, SLOT(slotClientDisconnected())); connect(tcpClient, SIGNAL(signalDataReceived(const std::string &)), this, SLOT(slotClientGetData(const std::string &))); connect(tcpClient, SIGNAL(signalError(const QString &)), this, SLOT(slotClientConnectionError(const QString &))); }
void CFrmLogin::on_pbRegitster_clicked() { disconnect(GET_CLIENT.data(), SIGNAL(sigClientConnected()), GET_MAINWINDOW, SLOT(slotClientConnected())); CDlgRegister r(this); int nRet = r.exec(); #ifdef RABBITIM_USE_QXMPP if(QDialog::Accepted == nRet) on_pbOk_clicked(); #endif }
void CFrmLogin::on_pbOk_clicked() { //停止自动登录定时器 if(m_tmAutoLogin.isActive()) m_tmAutoLogin.stop(); disconnect(GET_CLIENT.data(), SIGNAL(sigClientConnected()), GET_MAINWINDOW, SLOT(slotClientConnected())); bool check = connect(GET_CLIENT.data(), SIGNAL(sigClientConnected()), GET_MAINWINDOW, SLOT(slotClientConnected())); Q_ASSERT(check); disconnect(GET_CLIENT.data(), SIGNAL(sigClientError(CClient::ERROR_TYPE)), this, SLOT(slotClientError(CClient::ERROR_TYPE))); check = connect(GET_CLIENT.data(), SIGNAL(sigClientError(CClient::ERROR_TYPE)), SLOT(slotClientError(CClient::ERROR_TYPE))); Q_ASSERT(check); ui->lbePrompt->setText(tr("Being Login...")); GET_CLIENT->Login(ui->cmbUser->currentText(), ui->lnPassword->text(), m_Status); return; }