Ejemplo n.º 1
0
//слот - новое подключение
void MyServer::slotNewConnection(){
    socket = server->nextPendingConnection();
    connect (socket,SIGNAL(disconnected()),this,SLOT(slotClientDisconnected()));
    connect(socket,SIGNAL(disconnected()),socket,SLOT(deleteLater()));
    isClientConnected = true;
    messageLabel->setText("Client connected");
}
Ejemplo n.º 2
0
void CentralWidget::slotClientConnectionError(const QString &error)
{
    connectionStatusLabel->setText(tr(connetionStatus[CS_ERROR]) + error);
    connectButton->setEnabled(true);
    connError = true;

    slotClientDisconnected();
}
Ejemplo n.º 3
0
void CentralWidget::slotClientAbortConnect()
{
    disconnect(connectButton, SIGNAL(clicked()), this,
        SLOT(slotClientAbortConnect()));

    slotClientDisconnected();

    tcpClient->abort();
}
Ejemplo n.º 4
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 &)));
}