예제 #1
0
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()));
}
예제 #2
0
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();
}
예제 #3
0
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 &)));
}
예제 #4
0
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
}
예제 #5
0
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;
}