예제 #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 Server::disconnectAll()
{
    emit stopAllConnections();
}