Пример #1
0
void Server::incomingConnection(int socketDescriptor)
{
    qDebug() << "Server: incoming connection";

    QMutexLocker lock(&m_serverPropMutex);
    ServerConnection* connection = new ServerConnection(socketDescriptor, m_lossless, m_maxFramesInQueue, m_maxFramesInFlight);
	connection->setAcknowledgeNeeded(m_acknowledge);
	lock.unlock();

    // let errors go through the error reporting signal of this class
    connect( this, SIGNAL( onError(PlvErrorType,QString)),
             connection, SIGNAL(onError(PlvErrorType,QString)));

    // move the connection to its own thread
    QThreadEx* connectionThread = new QThreadEx();
    connection->moveToThread(connectionThread);

    // when the connection is done it is scheduled for deletion
    connect( connection, SIGNAL(finished()),
             connection, SLOT(deleteLater()));

    // when the connection is done, it stops its thread
    connect( connection, SIGNAL(finished()),
             connectionThread, SLOT(quit()));

    // start the connection when its thread is started
    connect( connectionThread, SIGNAL(started()),
             connection, SLOT(start()));

    // inform server when this serverthead is waiting on the client
    connect( connection, SIGNAL( waitingOnClient(ServerConnection*,bool)),
             this, SLOT( serverThreadStalled(ServerConnection*,bool)) );

    connect( parent(), SIGNAL( maxFramesInQueueChanged(int) ),
             connection, SLOT( setMaxFramesInQueue(int) ) ); //setMaxFrameInQueue &&maxFrameInQueueChanged added in TODO check

    connect( parent(), SIGNAL( maxFramesInFlightChanged(int) ),
             connection, SLOT( setMaxFramesInFlight(int)) );

    connect( parent(), SIGNAL( losslessChanged(bool) ),
             connection, SLOT( setLossless(bool)) );

    // stop this connection when stopAllConnections is called
    connect( this, SIGNAL(stopAllConnections()), connection, SLOT(stop()));

    // start the connection thread and its event loop
    connectionThread->start();

    // connection receives all broadcasts and sends it to its connection
    connect( this, SIGNAL( broadcastFrame(quint32,QByteArray)),
             connection, SLOT( queueFrame(quint32,QByteArray)));
}
Пример #2
0
void Server::incomingConnection(int socketDescriptor)
{
    qDebug() << "Server: incoming connection";

    ServerConnection* connection = new ServerConnection(socketDescriptor);

    // let errors go through the error reporting signal of this class
    this->connect( connection,
                   SIGNAL(errorOccurred(PipelineErrorType,QString)),
                   SIGNAL(error(PipelineErrorType,QString)));

    // move the connection to its own thread
    QThreadEx* connectionThread = new QThreadEx();
    connection->moveToThread(connectionThread);

    // when the connection is done it is scheduled for deletion
    connect( connection, SIGNAL(finished()),
             connection, SLOT(deleteLater()));

    // when the connection is done, it stops its thread
    connect( connection, SIGNAL(finished()),
             connectionThread, SLOT(quit()));

    // start the connection when its thread is started
    connect( connectionThread, SIGNAL(started()),
             connection, SLOT(start()));

    // inform server when this serverthead is waiting on the client
    connect( connection, SIGNAL( waitingOnClient(ServerConnection*,bool)),
             this, SLOT( serverThreadStalled(ServerConnection*,bool)) );

    // stop this connection when stopAllConnections is called
    connect( this, SIGNAL(stopAllConnections()), connection, SLOT(stop()));

    // start the connection thread and its event loop
    connectionThread->start();

    // connection receives all broadcasts and sends it to its connection
    connect( this, SIGNAL( broadcastFrame(quint32,QByteArray)),
             connection, SLOT( queueFrame(quint32,QByteArray)));
}
Пример #3
0
void RunDialog::on_runButton_clicked()
{
    activateConfiguration();

    Configuration* pConfig = Configuration::getConfig();

    string outputDirectory = ui->runName->text().toStdString();

    pConfig->setString("contigFileName", ui->contigFileName->text().toStdString());

    pConfig->setString("outputDirectory", outputDirectory);
    pConfig->setString("inputDirectory", outputDirectory);

    QThreadEx* pThread = new QThreadEx();
    _pRun = new RunQSNP();
    _pRun->moveToThread(pThread);
    connect(this, SIGNAL(cancelRun()), _pRun, SLOT(cancel()), Qt::DirectConnection);
    connect(pThread, SIGNAL(started()), _pRun, SLOT(run()));
    connect(_pRun, SIGNAL(done()), pThread, SLOT(quit()));
    connect(_pRun, SIGNAL(done()), this, SLOT(runDone()));
    connect(_pRun, SIGNAL(printMessage(QString)), this, SLOT(printMessage(QString)));

    pThread->start();
    printMessage(tr("Started"));

#ifndef QT_NO_CURSOR
    QApplication::setOverrideCursor(Qt::WaitCursor);
#endif

    ui->runButton->setEnabled(false);
    ui->stopButton->setEnabled(true);
    ui->browseButton->setEnabled(false);
    ui->editButton->setEnabled(false);
    ui->outputDirButton->setEnabled(false);
    ui->configurationComboBox->setEnabled(false);
}